Products API endpoint "Prices must be given as array of objects."

Im using python 3 to add a new product but I am getting a “Prices must be given as array of objects.”

put_payload = {
    "name": "Test",
    "code": 1,
    "unit": 1,
    'prices': [
      {
      'price': 10, 
      'currency': 'USD', 
      }
    ]
}

Full error message response:
{‘success’: False, ‘error’: ‘Prices must be given as array of objects.’, ‘error_info’: ‘Please check developers.pipedrive.com for more information about Pipedrive API.’, ‘data’: None, ‘additional_data’: None}

However if I omit the prices and use the below it works

put_payload = {
    "name": "Test",
    "code": 1,
    "unit": 1,
}

and my response is:

{'success': True, 'data': {'id': 5, 'name': 'Test', 'code': '1', 'description': None, 'unit': '1', 'tax': 0, 'category': None, 'active_flag': True, 'selectable': True, 'first_char': 't', 'visible_to': '3', 'owner_id': {'id': 1111111111, 'name': 'xxxxxxxxx', 'email': 'xxxxxxx', 'has_pic': 0, 'pic_hash': None, 'active_flag': True, 'value': 15907625}, 'files_count': None, 'followers_count': 0, 'add_time': '2022-08-22 21:13:39', 'update_time': '2022-08-22 21:13:39', 'prices': [{'id': 5, 'product_id': 5, 'price': 0, 'currency': 'USD', 'cost': 0, 'overhead_cost': None}]}, 'related_objects': {'user': {'1111111111': {'id': 1111111111, 'name': 'xxxxxx', 'email': 'xxxxxxxxx', 'has_pic': 0, 'pic_hash': None, 'active_flag': True}}}}

if you pull the prices format directly out of the response data you get:

      "prices":[
         {
            "id":5,
            "product_id":5,
            "price":0,
            "currency":"USD",
            "cost":0,
            "overhead_cost":"None"
         }
      ]

This is directly from the documentation as an example:

{
    "name": "",
    "code": "",
    "unit": "",
    "tax": "",
    "active_flag": "",
    "visible_to": "",
    "owner_id": "",
    "prices":[
        {
        "price": "", 
        "currency": "",
        "cost": "",
        "overhead_cost": ""
        }
    ]
}

Am I doing something wrong or is there a bug somewhere

Hi @nate :wave:

The example prices array you have provided has a comma after the currency field:

'prices': [
      {
      'price': 10, 
      'currency': 'USD', <---
      }
    ]

That could possibly be the reason your reason why your request is unsuccessful or something else with your code. May I suggest testing your request in our Postman collection? We have an example request there for adding a product.

Let us know if you have any further questions! :slight_smile: