Get order by user - Fabric
Get order by user
cURL
curl --request GET \
--url https://prod01-apigw.yourcompany.fabric.zone/api-order/orders/user \
--header 'Authorization: <authorization>' \
--header 'x-site-context: <x-site-context>'
Python
import requests
url = "https://prod01-apigw.yourcompany.fabric.zone/api-order/orders/user"
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "<authorization>"
}
response = requests.get(url, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'GET',
headers: {'x-site-context': '<x-site-context>', Authorization: '<authorization>'}
};
fetch('https://prod01-apigw.yourcompany.fabric.zone/api-order/orders/user', 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-apigw.yourcompany.fabric.zone/api-order/orders/user",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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"
"net/http"
"io"
)
func main() {
url := "https://prod01-apigw.yourcompany.fabric.zone/api-order/orders/user"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-site-context", "<x-site-context>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Unirest (Java)
HttpResponse<String> response = Unirest.get("https://prod01-apigw.yourcompany.fabric.zone/api-order/orders/user")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "<authorization>")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://prod01-apigw.yourcompany.fabric.zone/api-order/orders/user")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body
Response Codes
- 200: Success
- 400: Bad Request
- 403: Forbidden
- 500: Internal Server Error
Example Response
{
"query": {
"limit": 2,
"offset": 0,
"count": 19,
"orderTotalSum": 31719.46,
"orderAverage": 1669.45,
"totalQuantitySum": 132,
"statusCounts": {
"ORDER_CREATED": 13,
"ORDER_CONFIRMED": 0,
"ORDER_CANCELLED": 1,
"ORDER_PARTIALLY_SHIPPED": 0,
"ORDER_SHIPPED": 2,
"ORDER_PARTIALLY_DELIVERED": 0,
"ORDER_DELIVERED": 0,
"ORDER_RETURNED": 0,
"ORDER_PARTIALLY_RETURNED": 0,
"ORDER_PAYMENT_AUTHORIZED": 2,
"ORDER_PAYMENT_INVALID": 0,
"ORDER_FULFILLED": 0,
"ORDER_PARTIALLY_FULFILLED": 1
}
},
"orders": [
{
"_id": "60ca5d3dc0fac00008e64c91",
"customerEmail": "mike@fabric.inc",
"orderTotal": 90.5,
"status": "ORDER_CREATED",
"orderId": "8677-7648-19307",
"shipTo": [
{
"pickupPerson": {
"name": {"first": "John", "last": "Doe"}
}
}
],
"items": [
{
"title": "Garden Wood Sofa",
"price": 90,
"quantity": 1
}
],
"payments": [
{
"amount": 90.5,
"currency": "USD"
}
],
"createdAt": "2021-06-16T20:21:17.038Z"
}
]
}
Error Response
{
"message": "User is not authorized to access this resource with an explicit deny"
}
Headers
- x-site-context: A JSON object containing information about the source you wish to pull from, required.
- Authorization: Required.