cancel
Showing results for 
Search instead for 
Did you mean: 

Bad request' error 400 in Testcomplete POST request

SOLVED
Highlighted
Al2
Occasional Contributor

Bad request' error 400 in Testcomplete POST request

Hello,

 

I'm trying to send http POST request to a server to receive a JSON token.

I keep getting 'Bad Request' error. So far I have been unable to find out the real issue here.

There's not request payload required for this service call.  I've tried the same thing in postman/soapui, it  just works fine

 

If anyone can give me some direction here, I'd really appreciate it.

 

function httpPostRequest()
{
var address ="http://dc2-amopoclak.com:11114/services//auth"
var username = "ALPOLD"
var password = "XXXXXX"; 

  // Create the aqHttpRequest object
  var aqHttpRequest = aqHttp.CreatePostRequest(address, username, password);
  aqHttpRequest.SetHeader("Content-Type", "application/json");
  //There's not request payload for this
  var aqHttpResponse = aqHttpRequest.Send();
 if(aqHttpResponse.StatusCode == 200) { 
return true;
}else{ 
return false;
}

}

Thank you

Al

 

 

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: Bad request' error 400 in Testcomplete POST request

Hi @Al2,

 

If you followed all the instructions from the Documentation and they didn't help, I suggest that you refer this question to the Support Team. You can reach out to them here:

https://support.smartbear.com/message/?prod=testcomplete

 
---------
Tanya Gorbunova
SmartBear Community Manager

Join the annual community event and share your stories to win gifts
Wintertainment2019

View solution in original post

4 REPLIES 4
Community Manager

Re: Bad request' error 400 in Testcomplete POST request

Hi @Al2,

 

Could you please review the aqHttp.CreatePostRequest Method  article? You may need to perform some additional steps depending on the auth type.

 

BTW, why dodo you have a double slash in the URL?

http://dc2-amopoclak.com:11114/services//auth
 

 

---------
Tanya Gorbunova
SmartBear Community Manager

Join the annual community event and share your stories to win gifts
Wintertainment2019
Community Hero

Re: Bad request' error 400 in Testcomplete POST request

Hi,

 

> I've tried the same thing in postman/soapui, it  just works fine

Use some recording proxy (e.g. Fiddler) to record requests sent by SoapUI and TestComplete. Compare recorded requests and make the one sent from TestComplete to match those sent from SoapUI.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Al2
Occasional Contributor

Re: Bad request' error 400 in Testcomplete POST request

Thank you Tanya! I think I added a // by mistake while posting it here. I'm not using '//' in my code.

 

I reread this article, and the only difference I noticed evertime, my program doesn't have a request body for API call. I don't need a request body to make this POST call.

 

Thank you

Al2 

Community Manager

Re: Bad request' error 400 in Testcomplete POST request

Hi @Al2,

 

If you followed all the instructions from the Documentation and they didn't help, I suggest that you refer this question to the Support Team. You can reach out to them here:

https://support.smartbear.com/message/?prod=testcomplete

 
---------
Tanya Gorbunova
SmartBear Community Manager

Join the annual community event and share your stories to win gifts
Wintertainment2019

View solution in original post