Skip to main content

HI,

 

I've not used the HTTPCaller using a POST request and body attribution.

The API call constructed by the developer has been provided like this:

var client = new RestClient("https://sww.smartchartapi.co.uk/api/Authentication/request");

client.Timeout = -1;

var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");

request.AddHeader("Cookie", "ASP.NET_SessionId=xcqkvogm2bp2yxshsgx1ncbg; AspxAutoDetectCookieSupport=1; __AntiXsrfToken=e680dfae824a472088c01d6672ba8471");

var body = @"{

" + "\\n" +

@"  ""username"": ""SWWAPI"",

" + "\\n" +

@"  ""password"": ""***""

" + "\\n" +

@"}";

request.AddParameter("application/json", body,  ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

Console.WriteLine(response.Content);

 

I've set up the HTTP caller like this but am getting a bad result. Any ideas what I am doing wrong?

 

Capture2Capture

Try to replace the BODY with one line withouth newlines:

{" + "\\n" + @"  ""username"": ""SWWAPI"", " + "\\n" + @"  ""password"": ""***"" " + "\\n" +@"}

 

what is the error message?


Might use the https://jsonlint.com/ service to try to create a valid Json for your body. For instance it seems it might be:

 

{

"username": "SWWAPI",

"password": "***"

}


Might use the https://jsonlint.com/ service to try to create a valid Json for your body. For instance it seems it might be:

 

{

"username": "SWWAPI",

"password": "***"

}

I'm getting

HTTP/1.1 400 Bad Request - https://sww.smartchartapi.co.uk/api/Authentication/request

 

tried the one line for the body but no joy so I'll try constructing some JSON!


Might use the https://jsonlint.com/ service to try to create a valid Json for your body. For instance it seems it might be:

 

{

"username": "SWWAPI",

"password": "***"

}

Worked" Created valid JSON and passed it using the correct Content type. Thank you!


Reply