내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards
해결됨

HTTP Response is 200 but Response Body is empty.

Avatar

Level 3

Hello,

I've created a simple script for sending a POST request to an API with the "application/x-www-form-urlencoded" content type. Here's the script:


var http = new HttpClientRequest("URL");
http.header["Content-Type"] = "application/x-www-form-urlencoded";
http.header["Cache-control"] = "no-cache";
http.header["Connection"] = "keep-alive";
http.body = "param1=value1&param2=value2&param3=value3&param4=value4";

http.method = "POST";

http.execute();

logInfo(http.response.code);
logInfo(JSON.stringify(http.response));

http.disconnect();

When I run this script, I receive a response with a 200 status code, but the response body is empty.

I've reached out to the API technical team, and they have tested the API from their end. They confirmed that they are receiving the request correctly and sending a proper response.

Please note that we have also added the URL to the "urlpermissions" in the control panel.

Could this issue be related to the "application/x-www-form-urlencoded" content type? I would appreciate it if someone could review this and share their thoughts.

 

Screenshot:

krishnakanth_patnaik_cc_0-1696411767877.png

 

 

Thank you,
Krishna

 

 

 

 

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @krishnakanth_patnaik_cc 

 

Could you please try printing the body of the response, as "var result = http.response.body.toString();" or if the response is in JSON object try parsing it and then printing them "var result3 = JSON.parse(http.response.body);" . Also you can try the same connection once in POSTMAN to see a clear picture and connection parameters.

 

Regards

Akshay

원본 게시물의 솔루션 보기

2 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @krishnakanth_patnaik_cc 

 

Could you please try printing the body of the response, as "var result = http.response.body.toString();" or if the response is in JSON object try parsing it and then printing them "var result3 = JSON.parse(http.response.body);" . Also you can try the same connection once in POSTMAN to see a clear picture and connection parameters.

 

Regards

Akshay

"var result = http.response.body.toString();" this worked. Not sure why the JSON.stringify had an issue with this.

 

Thanks for the inputs.