Happy Business Starts Here

Re: Add Product via REST API

Valued Scholar

Add Product via REST API

I am trying to add a product via the REST API.

 

 I was doing a POST to https://rest.apisandbox.zuora.com/v1/object/product  with the following payload

 

{
  "SKU": "C39DD268-9ADA-423D-B02F-670D61608F75",
  "Name": "Test Product",
  "Description": "Test Product",
  "EffectiveStartDate": "2016-01-01",
  "EffectiveEndDate": "2036-01-01"
}


 but only occasionally do I get a successful response with the productId.    Most of the time I get 400 Bad Request and message: "An unexpected error occurred"

 

Thanks for any help you can give!

Mary 

2 REPLIES 2
Master

Re: Add Product via REST API

Hi @marymunsell

 

Your word "occasionally" caught me.

 

Have you specified the Content-Type in the request header as "application/json"?
For Postman, set this way:

content_type_01.png

 

When I was not specifying this, I have experienced that it may succeed or fail if I request with the same content.

Valued Scholar

Re: Add Product via REST API

Hmm, I am pretty sure I had that set to application/json.      Even though I was including the credentials in the header, it seemed to work consistently when I made a call to "/connections" first.   So that was my solution for now 🙂

 

Thanks for your input!