function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pradhap Rao 7Pradhap Rao 7 

400 bad request when posting

Hello All, 

Trying to get hang on Vision API . I am following this link : https://metamind.readme.io/docs/apex-qs-create-vf-page

I have generated my oauth token through here : https://api.einstein.ai/token

I am trying to create dataset, all I get is 400 bad request. I am using postman and trying this with a einstein enabled developer edition. 

What am i doing wrong here?

User-added image


 
Michael Machado 22Michael Machado 22
Are you uploading data to an existing dataset?  I don't see a link to the data in your body if so. 
karthikChockalingamkarthikChockalingam
I too got the same issue, Any solution ??
Sachin RamachandranSachin Ramachandran
Hi Karthik,
Could you please share the paramters you have used for uploading the dataset.

400 "Bad Request" happens when a required field is missing or when invalid input is passed. In the above case the API expects either "data" or "path" parameter pointing to dataset file either uploaded from local or a file hosted.

Uploading a image dataset should be either of the below two forms
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "data=@C:\Data\mountainvsbeach.zip" -F "type=image"  https://api.einstein.ai/v2/vision/datasets/upload
or 
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "path=http://einstein.ai/images/mountainvsbeach.zip" -F "type=image"  https://api.einstein.ai/v2/vision/datasets/upload
Detailed explanation on the use of the APIs can be found here: https://metamind.readme.io/docs/create-a-dataset-zip-async

Please keep us posted if you have more questions

regards,
Sachin
Andy Tillo 2Andy Tillo 2
If you're still wondering (I had the same issue), take out the "Content-Type" from your Header section field, and just call it from the Body section: grab the form-data from the Body tab...
Mr.HarryMr.Harry
Hey @Sachin Ramchandra 
I'm Facing error bit same, here when i'm creating Lead i'm getting error from external
Below is my error i'm getting
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, https://abc.salesforce.com/services/data/v54.0/sobjects/lead/ failed to send the lead, error response: {"IsMutuallyAuthenticated":false,"Cookies":[],"Headers":["Connection","Date","Set-Cookie","Strict-Transport-Security","X-Robots-Tag","Cache-Control","Sforce-Limit-Info","Content-Type"],"SupportsHeaders":true,"ContentLength":-1,"ContentEncoding":"","ContentType":"application/json;charset=UTF-8","CharacterSet":"UTF-8","Server":"","LastModified":"\/Date(16599-0400)\/","StatusCode":"BadRequest","StatusDescription":"Bad Request","ProtocolVersion":{"Major":1,"Minor":1,"Build":-1,"Revision":-1,"MajorRevision":-1,"MinorRevision":-1},"ResponseUri":"https://abc.salesforce.com/services/data/v54.0/sobjects/lead/","Method":"POST","IsFromCache":false}