Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

API calls with multiple fields in cURL


I am attempting to automate the creation of test plans in my environment. I am using cURL from the terminal and I have gotten most of the APIs I need to work (both GET and POST). However, I cannot seem to get the right syntax figured out for the get_cases API. This API requires at least two parameters and I don’t seem to be able to get the syntax correct. I referenced the API docs as well as a similar post on this same API in PHP. Currently, this is what I have:

curl -D- -u username:password -X GET
-H “Content-Type: application/json”

I have also tried

curl -D- -u username:password -X GET
-H “Content-Type: application/json”

both of these return an error message

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Date: Wed, 03 Feb 2016 21:15:41 GMT
Server: Apache
Content-Length: 48
Connection: keep-alive

{“error”:“Field :suite_id is a required field.”}

I’ve tried every variation I can think of for this command string without luck. Can someone please tell me what the correct syntax is? Preferably an example that has run using cURL against the cloud service


OK, I finally figured out my own problem. When your cURL command has concatenated parameters you have to surround your address in single quotes.

Like this

curl -D- -u username:password -X GET
-H “Content-Type: application/json”

This can be parsed correctly and returns the desired results.



Yes, was about to mention it but great to hear that you found it out already. The suite_id is also only required for multi-suite projects and optional/ignored for single-suite projects. The section_id is optional in both cases and lets you filter the cases list by section ID.