Tranquility refuses HTTP data

Hello,

I’m trying to send data to Druid via HTTP to Tranquility (Wikipedia Tutorial Config). Therefore I have implemented the following function:`

`
//Upload JSON-formatted Data to Druid
public async Task uploadEntries(string messages, string topic) {

        var content = new StringContent(messages, Encoding.UTF8, "application/json");

        HttpResponseMessage response;

        //curl -XPOST -H'Content-Type: application/json' --data-binary @quickstart/tutorial/wikiticker-2015-09-12-sampled.json http://localhost:8200/v1/post/wikipedia

        try {

            //Try to get a Response from the Druid Instance
            response = await client.PostAsync("http://" + ip + ":" + port + "/v1/post/" + topic, content);
        }
        catch {

            Console.WriteLine("ERROR: Didn't receive Response in Time.");
            return false;
        }
     
        //Check if the Query was successful
        if (!response.IsSuccessStatusCode) {

            Console.WriteLine("Upload failed due to: \n" + response.ReasonPhrase);
            return false;
        }

        return true;
    }

``

Calling it via

uploadEntries("{Line copied from Wikiticker example}", “wikipedia”);

``

Writes “Upload failed due to: Bad Request”.
Does anyone know, why this does not work?

Do I have to send a real byte-stream?

Best Regards,

Calvin

Does it work if you use run the curl command directly?

I’m not familiar with the libraries used in the sample code above, you could check the tranquility-server logs (under var/sv if you’re using the quickstarts) to see if they have any useful info.

It works, when I execute the command directly and it works from NodeRed HTTP Nodes, but I can’t get it to work with C#…

Nope, sadly there’s no useful information.

This might be a “heavyweight” approach, but maybe you could use Wireshark or similar tools to see how the request structure differs between the various cases