Parameters

There are two different ways to pass parameters in a request with the API.

The best way to pass parameters is as a JSON object containing the appropriate attribute names and values as key-value pairs. When you use this format, you should specify that you are sending a JSON object in the header. This is done by setting the Content-Type header to application/json. This ensures that your request is interpreted correctly.

curl -H "Authorization: $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"name": "Spring offer"}' \
    -X POST "$API_URL/$NETWORK_ID/campaign"

Another way of passing parameters is using standard query attributes.

Using this format, you would pass the attributes within the URI itself. Tools like curl can take parameters and value as arguments to create the appropriate URI.

With curl this is done using the -F flag and then passing the key and value as an argument. The argument should take the form of a quoted string with the attribute being set to a value with an equal sign.

curl -H "Authorization: $TOKEN" \
    -F "name=Spring offer" \
    -X POST "$API_URL/$NETWORK_ID/campaign"

You could also use a standard query string if that would be easier in our application. In this case, the parameters would be embedded into the URI itself by appending a ? to the end of the URI and then setting each attribute with an equal sign. Attributes can be separated with a &.

curl -H "Authorization: $TOKEN" \
     -X POST \
     "$API_URL/$NETWORK_ID/campaign?name=Spring%20offer"