Community
Showing results for 
Search instead for 
Do you mean 
Reply

Error 400 Bad Request

Accepted Solution Solved
Copper Super Contributor
Posts: 58
Country: USA
Accepted Solution

Error 400 Bad Request

I can read contacts and update them, but the same approach fails when trying to CREATE a contact. 

 

Any suggestions?   required fields?    The example has an ID, so is a GUID required??? 

 

We  tried all fields,  a few, only First name and Last name,  with and without ID and Record Owner.

 

What's up with doing a successful a contact POST?

 

 

Alan Lee

ACC in Chicago

www.OAK!Merge.com 

 

 


Accepted Solutions
Solution
Accepted by topic author alanmlee
‎05-12-2016 07:16 PM
Employee
Posts: 236
Country: USA

Re: Error 400 Bad Request> json to Create a new contact. Fails with error 400

I removed the last field (Created) and conact POST works just fine.  You'll note that the Created field is read-only in Act!.  You also shouldn't pass in Id nor RecordOwner.

View solution in original post


All Replies
Employee
Posts: 236
Country: USA

Re: Error 400 Bad Request

You shouldn't need the ID, since that's generated and returned in the location header.  

 

Can you post a sample json model?  

Copper Super Contributor
Posts: 58
Country: USA

Re: Error 400 Bad Request> json to Create a new contact. Fails with error 400

{
"FirstName": "John",
"LastName": "Smith",
"MiddleName": null,
"NameSuffix": null,
"NamePrefix": null,
"Salutation": null,
"Company": null,
"CompanyId": null,
"JobTitle": "Man In Charge",
"Department": "Space Fontier",
"EmailAddress": "LamesJawson@jawson.email",
"AltEmailAddress": "abc@abc.com",
"PersonalEmailAddress": "personal@yahoo.com",
"BusinessPhone": "(503) 555-2232",
"BusinessExtension": null,
"MobilePhone": "(503) 555-1212",
"MobileExtension": null,
"HomePhone": "(407) 555-2020",
"HomeExtension": null,
"AlternatePhone": null,
"AlternateExtension": null,
"FaxPhone": "(503) 555-1234",
"FaxExtension": null,
"PagerPhone": null,
"PagerExtension": null,
"BusinessAddress": {
"Line1": "10 Countdown Loop",
"Line2": "Monolithe 500",
"Line3": "Room 1001",
"City": "Bogusta",
"State": "OR",
"PostalCode": "97800",
"Country": "United States"
},
"HomeAddress": {
"Line1": "10 Rocket Rd.",
"Line2": "Space 2001",
"Line3": null,
"City": "Bogus",
"State": "OR",
"PostalCode": "97804",
"Country": "United States"
},
"Website": "www.jawson.org",
"Birthday": null,
"CustomFields": null,
"IdStatus": "Customer",
"ContactType": "Contact",
"Id": null,
"RecordOwner": "Chris Huffman",
"Created": null
}

Solution
Accepted by topic author alanmlee
‎05-12-2016 07:16 PM
Employee
Posts: 236
Country: USA

Re: Error 400 Bad Request> json to Create a new contact. Fails with error 400

I removed the last field (Created) and conact POST works just fine.  You'll note that the Created field is read-only in Act!.  You also shouldn't pass in Id nor RecordOwner.

New Member
Posts: 7
Country: New_Zealand

Re: Error 400 Bad Request

I am having a similar issue. I get error 400 when posting to /api/Contacts. However, this is in code that has been working fine for several weeks. Suddenly it's throwing error 400. No other information at all. Are there any log files anywhere that actually tell you what the problem is? In this case I'm baffled because it was working absolutely fine, but now it isn't. Event using the test page of the API with my payload and appropriate bearer token results in error 400. This is what I'm sending:

 

{"isUser":false,"idStatus":"Referral","firstName":"John","lastName":"Doe","homeAddress":{"line1":"1 example  road","line2":"","line3":"","city":"Any Town","postalCode":"","state":"Bay of Plenty","country":"New Zealand"},"mobilePhone":"02 111111","birthday":"1994-01-01","customFields":{"gender":"Male","lor date received":"2016-06-30","swn":"123-456-789","supervisor":"John Smith"}}

 

Can anyone suggest a reason why code that worked happily is suddenly completely broken?

New Member
Posts: 7
Country: New_Zealand

Re: Error 400 Bad Request

...and as usual after tearing what remains of my hair out, I find the problem. The client had decided that one of the custom fields should be read only and had changed it without notifying me.

I have to say though, that simply throwing out 400 is a pretty poor response. Why can we not have an exception or other debug message as well as the 400 status? It would make debugging far easier and remove the trial and error guesswork. Even a log file somewhere would be useful.
Employee
Posts: 236
Country: USA

Re: Error 400 Bad Request

Hi, 

 

A 400 HTTP status code is actually the right thing for any data validation issue.  If you look at other REST APIs you'll see that's a standard, and for good reason, it's based off of HTTP spec (https://tools.ietf.org/html/rfc7231#section-6.5.1). 

 

However, your point is valid that we should provide more information as part of bad request 400 message, most notable the field(s) that are problematic, and some detail.

 

This is on the backlog to deliver.

 

--Xavier

 

New Member
Posts: 7
Country: New_Zealand

Re: Error 400 Bad Request

Thanks for the response. Looking forward to seeing this resolved. For the record I have no issue with 400 being returned - only that it's returned in isolation. On its own it's not clear if there is an issue with the client request (400 is returned by most web servers in response to a gibberish request) or whether it's an application/permission issue as in this case.