Login Page - Create Account

Support Board


Date/Time: Sat, 20 Apr 2024 09:44:21 +0000



HTTPResponse always empty - used in conjunction with tradingsystem example code

View Count: 371

[2022-05-20 16:38:00]
ray42 - Posts: 21
Hi,

I'm using the example function `scsf_GetOrderFillEntryExample` from the file TradingSystem.cpp.

In this function, I'm trying to send a HTTP POST message to a server.

Here is what happens:

1. The post works
2. server receives the data
3. server also sends the data (confirmed from logs and testing in local system - localhost)

The issue is that the HTTPresponse object is always empty.


```
      sc.AddMessageToLog("Preparing to send message", 0);
      
      if (RequestState == REQUEST_NOT_SENT){
        if (!sc.MakeHTTPPOSTRequest(PostURL, PostMessagae, &HTTPHeader, NumberOfHeaders)){
          sc.AddMessageToLog("Error making HTTP request.", 0);
          RequestState = REQUEST_NOT_SENT;
        }else{
          RequestState = REQUEST_SENT;
          sc.AddMessageToLog("HTTP Request Sent Successfully!", 0);
        }
      }
      
      if (RequestState == REQUEST_SENT && sc.HTTPResponse != ""){
        RequestState = REQUEST_RECEIVED;
        //sc.AddMessageToLog("HTTP req COMPLETE!", 0);
        // Display the response from the Web server in the Message Log
        sc.AddMessageToLog(sc.HTTPResponse, 0);
      }else if (RequestState == REQUEST_SENT && sc.HTTPResponse == ""){
        //The request has not completed, therefore there is nothing to do so we will return
        //sc.AddMessageToLog("HTTP req NOT complete yet", 0);
      }
      sc.AddMessageToLog(sc.HTTPResponse, 0);
```

Am I missing anything here? I'm using a python backend Django and sending a HttpResponse object (https://docs.djangoproject.com/en/4.0/ref/request-response/#django.http.HttpResponse).

Is there anything I should do differently in the sierrachart code?

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account