Update invoice for financial posting - Fabric
Update invoice for financial posting
cURL
curl --request POST \
--url https://prod01.oms.fabric.inc/api/v2/invoice/post \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '\n{
"invoiceIds": [\
"invoiceId1",\
"invoiceId2"\
]\
}\n'
Python
import requests
url = "https://prod01.oms.fabric.inc/api/v2/invoice/post"
payload = { "invoiceIds": ["invoiceId1", "invoiceId2"] }
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({invoiceIds: ['invoiceId1', 'invoiceId2']})
};
fetch('https://prod01.oms.fabric.inc/api/v2/invoice/post', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [\
CURLOPT_URL => "https://prod01.oms.fabric.inc/api/v2/invoice/post",\
CURLOPT_RETURNTRANSFER => true,\
CURLOPT_ENCODING => "",\
CURLOPT_MAXREDIRS => 10,\
CURLOPT_TIMEOUT => 30,\
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
CURLOPT_CUSTOMREQUEST => "POST",\
CURLOPT_POSTFIELDS => json_encode([\
'invoiceIds' => [\
'invoiceId1',\
'invoiceId2'\
]\
]),\
CURLOPT_HTTPHEADER => [\
"Authorization: Bearer <token>",\
"Content-Type: application/json",\
"x-site-context: <x-site-context>"\
],\
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://prod01.oms.fabric.inc/api/v2/invoice/post"
payload := strings.NewReader("{\n \"invoiceIds\": [\n \"invoiceId1\",\n \"invoiceId2\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Unirest (Java)
HttpResponse<String> response = Unirest.post("https://prod01.oms.fabric.inc/api/v2/invoice/post")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"invoiceIds\": [\n \"invoiceId1\", \n \"invoiceId2\"\n ]\n}")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://prod01.oms.fabric.inc/api/v2/invoice/post")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"invoiceIds\": [\n \"invoiceId1\",\n \"invoiceId2\"\n ]\n}"
response = http.request(request)
puts response.read_body
Possible Responses
- 201: Invoice updated
- 400: Bad Request
- 404: Invoice not found
- 500: Internal Server Error
Request/Response Schema
Authorization
Authorization: Requires a Bearer token in the header.
Headers
x-site-context: JSON object containing source context information (mandatory)
Body
invoiceIds: List of invoice IDs (required)
Response Example
[
{
"invoiceId": "62ff5c0bec0aed3c86202c32",
"shipmentId": "62ff5c0bec0aed3c86202c32",
"statusCode": "CREATED/POSTED/ACKNOWLEDGED",
"channelId": "strate",
"invoiceTotal": 245.7,
"totalTaxAmount": 245.7,
"currency": "dollar",
"invoiceNumber": "23940791",
"invoiceStatus": "CAPTURED/SETTLED",
"invoiceType": "SHIPPING/APPEASEMENT",
"invoiceDate": "2022-08-01T20:03:28.483971941Z",
"shipmentNumber": "217088603",
"shippedOn": "2022-08-01T20:03:28.483971941Z",
"orders": [...],
"customer": {...},
"attributes": {}
}
]
Replace <token> and <x-site-context> with appropriate values when implementing this.