error:"Unknown field 'org_name' in your request."

I’ve been trying to use the Pipedrive API to add a person to the contacts list via a web-application. However, I keep encountering an HTTP 400 error when sending a Post Request to the API using the Backbone.js save() function. The response body says that the API does not recognize one of the fields I am trying to pass , ‘org_name’.

This is the console response I get:
“HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax.
(XHR)POST - https://api.pipedrive.com/v1/persons?api_token=####

This is my request body:
{“name”:"####",“phone”:"",“email”:"",“org_name”:"####",“assistant”:"",“location”:"",“groups”:"","_id":###}

And this is the response body:
{“success”:false,“error”:“Unknown field ‘org_name’ in your request.”}

This is especially puzzling to me, since this is the name of one of the fields I am retrieving from the API with a GET request using the Backbone.js fetch() function.

This code is working perfectly:
collection.fetch();
model.set(‘org_name’, item.org_name);

But for some reason, this code is not:
model.set(‘org_name’, $(’.org-input’).val());
model.save( null, {type: ‘POST’});

I’ve tried searching for what could be wrong with my code such that this happens, and the closest I could find to an answer was a separate thread in this community : (400) Bad Request Error on Create Activity . Unfortunately, this does not quite answer my question.

If anyone knows what could be wrong, how I may fix this, or if you need more details, please let me know.

Hi. When adding a person, you should provide org_id instead of the org_name. You can take a look here: https://developers.pipedrive.com/docs/api/v1/#!/Persons/post_persons

If you need to add a new organization, you can do it at this endpoint: https://developers.pipedrive.com/docs/api/v1/#!/Organizations/post_organizations
It will reply with the new id, and you can then use it in your request to add the person, as org_id.

Let me know if it helps :slight_smile: