Curl help input data

Hi there I need your help! Loving Xojo but I am getting started again.

I am busy with a webservice using Curl.

I bought the https://www.monkeybreadsoftware.de/xojo/plugin-curl.shtml plugin and it really works well.

i managed to provide my required header by just adding:

c.SetOptionHTTPHeader array("Authorization: Key xxxxxxxx", "Content-Type: application/json")

Now i need to provide inputs for my below service:

curl -X POST \\ -H "Authorization: Key YOUR_API_KEY" \\ -H "Content-Type: application/json" \\ -d ' { "inputs": [ { "data": { "image": { "url": "https://samples.com/metro-north.jpg" } } } ] }'\\ https://api.samples.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs

but how do i provide the input part as seen above "inputs": [ { "data": { "image": { "url": "https://samples.com/metro-north.jpg"

part?

dim d as string = (I NEED TO ADD THE INPUT DATA HERE) c.InputData =d

Also do i need to set c.optionput =true ?

Looking forward to some help here! Thanks in advance!

Please remove c.optionput as you need post.

And use OptionPostFields to put in the JSON text.

e.g.

[code]dim c as new CURLSMBS

c.OptionVerbose = true
c.OptionURL = URL
c.SetOptionHTTPHeader array(“Authorization: Key xxxxxxxx”, “Content-Type: application/json”)
c.OptionPostFields = YourJSON

dim e as integer = c.Perform

DebugTextArea.Text = c.DebugData
ResultTextArea.Text = c.OutputData[/code]

[quote=400840:@Christian Schmitz]e.g.

[code]dim c as new CURLSMBS

c.OptionVerbose = true
c.OptionURL = URL
c.SetOptionHTTPHeader array(“Authorization: Key xxxxxxxx”, “Content-Type: application/json”)
c.OptionPostFields = YourJSON

dim e as integer = c.Perform

DebugTextArea.Text = c.DebugData
ResultTextArea.Text = c.OutputData[/code][/quote]

Ok and how to parse the input data to YourJSON?

I would expect you have that JSON in a variable and pass it there.
Or use JSON Classe in Xojo or plugin to build/parse it.

Ok I got it! I parsed the raw JSON as string to test and it worked. The output was confusing as the webservice returned data that I was not expecting. However all clear now.

Great module!