Generate URL to bulk upload price details - Fabric
Generate URL to bulk upload price details
cURL
curl --request POST \
--url https://live.copilot.fabric.inc/api-pim/item/upload-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '\n{\n "fileName": "file1.csv",\n "type": "price"\n}\n'
Python
import requests
url = "https://live.copilot.fabric.inc/api-pim/item/upload-url"
payload = {
"fileName": "file1.csv",
"type": "price"
}
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
const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({fileName: 'file1.csv', type: 'price'})
};
fetch('https://live.copilot.fabric.inc/api-pim/item/upload-url', 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://live.copilot.fabric.inc/api-pim/item/upload-url",\
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([\
'fileName' => 'file1.csv',\
'type' => 'price'\
]),\
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://live.copilot.fabric.inc/api-pim/item/upload-url"
payload := strings.NewReader("{\n \"fileName\": \"file1.csv\",\n \"type\": \"price\"\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))
}
Java (Unirest)
HttpResponse<String> response = Unirest.post("https://live.copilot.fabric.inc/api-pim/item/upload-url")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileName\": \"file1.csv\",\n \"type\": \"price\"\n}")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://live.copilot.fabric.inc/api-pim/item/upload-url")
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 \"fileName\": \"file1.csv\",\n \"type\": \"price\"\n}"
response = http.request(request)
puts response.read_body
Expected Responses
200
{
"url": "https://example.s3.amazonaws.com/pricelist/123/dev02/123-priceList1.csv?X-Amz-Algorithm...x-amz-meta-stage=dev02",
"keyId": "1646680518524-priceList1"
}
400
{
"code": "BAD_REQUEST",
"message": "Bad Request"
}
500
{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error."
}
Authorizations
- Authorization:
Bearer <token>
Required authentication header of the formBearer <token>.
Headers
- x-site-context:
Required. Thex-site-contextheader is a JSON object containing information about the source.
Body
fileName:
Name of the file to upload (e.g.,"file1.csv").type:
Folder to save the CSV files, available options:price,price-range,price-range-sku.
Example:"price"
Response
url:
URL to upload the CSV (valid for 5 minutes).
Example:"https://example.s3.amazonaws.com/pricelist/123/dev02/123-priceList1.csv?X-Amz-Algorithm...x-amz-meta-stage=dev02".keyId:
Key ID associated with the file (e.g.,"1646680518524-priceList1").