HTTp to REST without response

AitorEGAitorEG Member Posts: 342
Hi everyone,

I'm sending a file to a Rest WebService, in this way:
HttpWebRequest := HttpWebRequest.Create('http://eshop.xxxxx-eu.com/ws/api/rest');
 HttpWebRequest.Method := 'POST';
 HttpWebRequest.ContentType('application/x-www-form-urlencoded');
 postString := STRSUBSTNO('json=%1',pJson);
 StreamWriter := StreamWriter.StreamWriter(HttpWebRequest.GetRequestStream);
  StreamWriter.Write(postString);
  StreamWriter.Close;
  StreamWriter.Dispose;
  HttpWebRequest.GetResponse;
But I'mn getting an error in the WebResposne, becasue the server is not responding anything. How can i "run" the request without expecting any response?

Thank you very much

Answers

  • ShaiHuludShaiHulud Member Posts: 228
    You could put the HttpWebRequest.GetResponse into a TryFunction. That way even if it fails, you can continue.

    However, how would the server send no response? There must be at least basic (OK (Response Code 200)) response, even if there's nothing in the response body.
  • RobyRRobyR Member Posts: 39
    I tried to connect to that URI with a browser and I can't reach the server, are you sure your API is accessible?
  • AitorEGAitorEG Member Posts: 342
    RobyR wrote: »
    I tried to connect to that URI with a browser and I can't reach the server, are you sure your API is accessible?
    The URI I've wrote obviously is not the real, is from one of our customer's URL.... ;-). Thanks anyway
  • AitorEGAitorEG Member Posts: 342
    ShaiHulud wrote: »
    You could put the HttpWebRequest.GetResponse into a TryFunction. That way even if it fails, you can continue.

    However, how would the server send no response? There must be at least basic (OK (Response Code 200)) response, even if there's nothing in the response body.

    I know it has no sense, so after talking to the provider, they've changed the servie to get a response, and the problem finally is solved
Sign In or Register to comment.