3

enter image description here

I have limited knowledge to use form-data for the request.

I created a body as

--usersjiaosd9821931-FGGHJ
Content-Disposition: form-data; name="users"; filename="users.json";

Content-Type: application/json

[{"email": "[email protected]","password": "alwaysPostFakePasswords"}, {"email": "[email protected]","password": "sdfnDAqpAdoQF&www344"}]
--usersjiaosd9821931-FGGHJ
Content-Disposition: form-data; name="connection_id"

con_test
--usersjiaosd9821931-FGGHJ--

From the screenshot, the user.json is [{"email": "[email protected]","password": "alwaysPostFakePasswords"}, {"email": "[email protected]","password": "alwaysPostFakePasswords"}]

I built something in Salesforce Apex like

HTTP http = new Http();
Httprequest request = new HttpRequest();
request.setEndpoint('The url to /api/v2/jobs/users-imports');
request.setMethod('POST');
request.setHeader('Accept', 'application/json');
request.setHeader('Content-Type','multipart/form-data; boundary=--usersjiaosd9821931-FGGHJ');
request.setBody(body);
response = http.send(request);
System.debug(response.getBody());

I keep getting {"statusCode":400,"error":"Bad Request","message":"Must provide 'users' file as multipart part.","errorCode":"invalid_body"}

1

1 Answer 1

1

I found out the boundary in the header does not need to include the --. All good thanks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .