0

I have a curl request to an api thus:

curl xx.yy.zz:8080 -X POST --data "bb=True&alg=egbis&image_url=https://someurl.com/someimage.jpg"

and this returns valid json results back.

Now trying to call this from a C# application using Unirestthus:

        string postData = "\"bb=True&alg=egbis&image_url=" + url + "\"";
        HttpResponse<string> jsonResponse = Unirest.post("http://xx.yy:8080/")
                .body(postData)
                .asJson<string>();

Have also tried without a double-quote preceding the bb=true and including/excluding the --data param in post string.

But keep getting this error: "{\"error\":\"not indexable\"}\r\n"

Have been stuck on this for the last couple of hours, pretty sure it's something silly, but am at a loss.

Thanks in advance for any help!

Santino
  • 776
  • 2
  • 11
  • 29

1 Answers1

0

Figured it out should pass the params as values

        HttpResponse<string> jsonResponse = Unirest.post("http://xx.yy")
            .field("bb","true")
            .field("alg","egbis")
            .field("image_url",url)
                .asJson<string>();
Santino
  • 776
  • 2
  • 11
  • 29