
How do I get curl to send the data in a way that the Trello server will accept? I'd like the option of the data being either in a file or in a shell variable. So I'm pushing back at answers that are of the form "do it in the usual way" because I don't know what that "usual way" is.

That was a hard glitch to debug because it was hard to determine where, among several levels, the error was actually occurring and I'm pretty new at all this.
#Curl json helper how to
But I'm looking for more specifics about how to actually construct the curl command.įor instance, the sample commands on the API Introduction page that we both cited have constructions like this: curl ''īut when I inserted $MyKey and $MyToken values into that string, I got an error from the shell because the single quotes had to be changed to double quotes so that the variables will be expanded to their values. Here’s how you can use curl to send a POST request with a JSON body: Create a JSON file Create a JSON file that contains the data you want to send in the request body. It can be used to send a variety of different HTTP requests, including POST requests with a JSON body. Your answer is, briefly, yes, that ought to work. The curl command line utility is a powerful tool for making HTTP requests. I believe that I have to add this to the curl options to have it properly upload JSON data: -header "Content-Type: application/json" What I'm interested in is being able to have a more complex creation command read from a file or from a shell variable that is in JSON format. The idList, name, and pos data are all provided on the curl command line and the response is piped through jq to display only the name and pos of the created card, as confirmation. In the above $WhoMe contains my token and key. So far, in my shell script, I have a construction like this: curl -s \ That's the page I linked to in my question.
