Send a POST request with get parameters


#1

Hi there,

I'm trying to send a post request with a generated XML with some GET parameters. The thing here is that the core is puting the get params in the post, so I end up having a post with the XML and the get params and the server just give me an error.

This is the code that I have for the post:

 

Http::Response* Http::sendPost (String urlStr,
                                StringArray parameterNames,
                                StringArray parameterValues,
                                String& postData)

{
    // If you hit this point it means that you are trying to send a POST request without any content.
    jassert (postData.length() != 0);

    URL url = URL (urlStr).withPOSTData (postData);
    
    for (int i = 0; i < parameterNames.size(); i ++)
        url = url.withParameter (parameterNames[i], parameterValues[i]);

    URL::OpenStreamProgressCallback* staticProgressCallback = &Http::openStreamProgressCallback;
    openStreamProgressCallback (this, 0, 0);
    Response* response = new Response();

    InputStream* inputStream = url.createInputStream (true,
                                                      staticProgressCallback,
                                                      this,
                                                      String(),
                                                      timeOut,
                                                      &(response->_responseHeaders),
                                                      &(response->_statusCode));

    response->setInputStream (inputStream);
    return response;
}

Can anybody help me?

 

Thanks!