Can’t set body content with script

Hello guys,
I’ve faced some problem. Well I can’t set body content with script. I can set it easly using object repository, but for some reason I can’t set it with script method. Here is what have I tried:
image

I get an error with the code 415 and the body content is empty when I try to log it.

Hi,

just a guess - try to set Content-Type for your HttpTextBodyContent - default one is text/plain.

... new HttpTextBodyContent(params, "UTF-8", "application/json")

2 Likes

Thanks Marek, I forgot to set the content-type into the header.
Thanks !

‘Set header’
ArrayList headers = new ArrayList()
headers.add(new TestObjectProperty(‘Content-Type’, ConditionType.EQUALS, ‘application/json’))
request.setHttpHeaderProperties(headers)