Error in Create product API

Hi All,

I am trying to create a product in sage via API. In this process I am getting an Unexpected Error message. I have attached both my request and response here.

Request:

curl -X POST \
api.accounting.sage.com/.../products \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Bearer eyJhbGciOiJSUzUxMiIsImtpZCI6IjFQWGpwTC05TWdXM0k0MkxITzhLdzYxN3RWUXdLTkRNQUNiQXRoSGtDRmc9In0.eyJqdGkiOiI3NTMxOTA2Ni1kODc5LTRmZDMtYmU0Zi1iNjQ3Mzk3MWMxMzEiLCJpYXQiOjE1NzMxOTc5ODgsImV4cCI6MTU3MzE5ODI4OCwiaXNzIjoib2F1dGguYXdzLnNiYy1hY2NvdW50aW5nLnNhZ2UuY29tIiwic3ViIjoiZGRjMWY1MDAtNjcxNi00ODQ1LWJmNmYtMTllOTQwZDJkZjZjIiwiYXVkIjoiYXBpLnNiYy1hY2NvdW50aW5nLnNhZ2UuY29tIiwiYXpwIjoiOTJhNWVmODYtZWNiNS00NzJlLWI2NzAtOTQzYTkzMDUyZmRjLzI4Mzg2YjViLTNkM2YtNDkzZi04Y2Y2LWZkNzIwYzZjYjZjNCIsImNvdW50cnkiOiJVUyIsInNjb3BlcyI6ImFjY291bnRpbmc6cncgY29yZTpydyIsInVzYWdlX3BsYW5fY29kZSI6ImV4dGVybmFsIn0.YYYJ4ECbG7M91fns5PbBOmqj0M4C31BlIvItUcWilpHEFYsB6Qclct173g4KIu6yZqPi-bmZIjhQpevO2AI853F0S9rRmUkrtq4n-t6RqcYyt_enL35w46fwaADTXzjX-F3TE90w30USyJjygKm5AbpUwPMvyhGBfQz1adJ5PBckSsKi4jurqvlHkQ1sVG-91ApRrMsflrhrxbT12Y_-GbJzmuI2Ls9Zes3pb_XmBKzfhhAy0A_vkdcij0QgmgLO1cv8nDCKdOqok-aOACcdk58vf87VylNf_-EJLQ9Ejmthvuxpwqj6H2t2RfH25dZFfmHGPq7t9pd0CioqNqByr66Yo4ShuKADeF7eLuI59ui30LzB0DFOo5ikkaAj9X8uVz3W6n5_lnySEMC3f50ZU_kVc4IXpDjbZKwo5lKgUJdgLYqXtwBh-z8EvZd-oepkG0obUpMnazRLmDZ4g-Y8qyYfbCkdkOtX2HV2nq6n6YInBIFOoJ2YVM4eD-06kScho-Y6Bwu4m8fY9BAAZ0IW9MRQ8wjZlgkm2RSeQFcSncPaiCsMfPjaby8djE05xCrOpjMD6sfd9P8F0EGBvsj6zeTY0r9ftEDLj0PP3MiVHEjIygVKy1tDni_9TEeUdZ_HWNVhtX619iBIk7ygV1R31tYRTcyjw9o8SEMb0ew3l4w' \
-H 'Content-Type: application/json' \
-H 'Cookie: __cfduid=d90518a7fae3cc09b2045079c8caf3efa1571644394; mmapi.store.p.0=%7B%22mmparams.d%22%3A%7B%7D%2C%22mmparams.p%22%3A%7B%22pd%22%3A%221603180973440%7C%5C%22-1835342940%7CAQAAAApVAwBR2CmjRBLEJgABEgABQgBIxpKWAQDNoAQT%2FVXXSM2gBBP9VddIAAAAAP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAZEaXJlY3QBRBIBAAAAAAAAAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAAAAAAAAFF%5C%22%22%2C%22bid%22%3A%221571645573060%7C%5C%22lvsvwcgeu01%5C%22%22%2C%22srv%22%3A%221603180973447%7C%5C%22lvsvwcgeu01%5C%22%22%7D%7D; _ga=GA1.2.242851357.1571644976; _gcl_au=1.1.208077119.1571644976; _fbp=fb.1.1571644977017.1306313822; _hjid=36d62f8d-aef1-4b97-8a87-1166f1f04338; LPVID=VkMmNhOTU3NzY0ZWE3YTE1; ELOQUA=GUID=650C6E08FA7F4C23A825225EE7062366; utag_main=v_id:016ded572a62004e1a8204b8101800096003a08e00838$_sn:1$_se:5$_ss:0$_st:1571647114975$ses_id:1571644975716%3Bexp-session$_pn:1%3Bexp-session' \
-H 'Host: api.accounting.sage.com' \
-H 'Postman-Token: 1d1474d0-f2db-4709-93b4-d80c104b9596,8416e40a-7e6b-4872-9542-b356554860a4' \
-H 'User-Agent: PostmanRuntime/7.18.0' \
-H 'cache-control: no-cache' \
-d '{
"product": {
"description": "Test",
"sales_ledger_account_id": "b21862baec2c11e9934112dfbffd6e70",
"purchase_ledger_account_id": "b218a5acec2c11e9934112dfbffd6e70",
"item_code": "TS",
"notes": "Test notes",
"sales_tax_rate_id": "bf24ef22b5334810a6cc6f9d147b5d35",
"usual_supplier_id": "",
"purchase_tax_rate_id": "bf24ef22b5334810a6cc6f9d147b5d35",
"cost_price": "9",
"sales_prices": [
"6",
"7"
],
"source_guid": "",
"purchase_description": "GTEdt",
"active": "true"
}
}'

Response : 

[
{
"$severity": "error",
"$dataCode": "UnexpectedError",
"$message": "An unexpected error occurred.",
"$source": ""
}
]

Please help me to sort out this issue.

Thanks in Advance,

Anbu

  • Hi 

    Unfortunately, our API reference is wrong for sales prices in the POST/PUT body of products/services.

    To be able to successfully create a new item, you need to send the following structure for sales prices:

            
    "sales_prices": [
        {
            "product_sales_price_type_id": YOUR_PRODUCT_SALES_PRICE_TYPE_ID,
            "price": YOUR_PRODUCT_PRICE,
            "price_includes_tax": true/false
        }
    ]

    I hope this helps you creating products. Please don't hesitate to ask if you have any further question around this.

    Regards, Tim