hi all, does anyone know how do I force http modul...
# suitescript
s
hi all, does anyone know how do I force http module to send xml body? I tried add header content-type to application/xml and it still sent out as json
b
what code are you trying with?
s
suitelet
b
script type is not code
s
Copy code
var _headerObj = ({
    'Authorization': _token,
   'Content-Type': 'application/xml'
});
var response = http.post({ url: ‘target url’, body: xmlString, headers: _headerObj });
b
that should set the content-type header
how do you know its being sent as json?
s
The response message states the media type is incorrect
b
what status code or error message
s
500
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
b
you can try using a echo service like httpbing.org/post to see what headers are being sent in your request
the server you are working with is throwing a generic error code, but you should probably also make sure the accept header has an acceptable value
s
thanks… solved. I should add accept header like this ‘Accept’:‘text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8’ and then it worked
thank you