Hi! Does anyone else have problems using the https...
# suitescript
n
Hi! Does anyone else have problems using the https module to post to external systems from a Suitelet? I'm getting 400 bad request.. Just sending an object as body: Code:
Copy code
var response = <http://https.post|https.post>({
                    url: "<url>",
                    body: body,
                    headers: {
                        "Content-Type": "application/json",
                        "Authorization": "Basic XXXXXXXXXXXXXXXXXXXXX"
                    }
                });
Where body is this:
Copy code
var body = {
                    "manufacturerCode": "3",
                    "code": "D21025139",
                    "variantPartNos": [
                        "D21025139_19034_89",
                        "D21025139_19035_89"
                    ],
                    "flag": "STATUS_READY"
                };
The same request in Postman works fine..
b
stringify the body
passing an object is telling https to do a form post
👍 1
n
🤦‍♂️ thanks @battk!... helped, getting 406 not acceptable now though, you know anything about that?
s
Try adding an "Accept" header for whatever response type you should be getting back
Most web services don't need it, but I have run across a few that do
n
@scottvonduhn Worked, thanks a lot, never got that before! 🙂
s
it's not common, but some services require it 🤷‍♂️
n
🙂 thanks a lot guys!