Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed reference to /meta per DOC-4422

...

Warning
titlePUT overwrites arrays unless 'append=true' is added to query string

For PUT requests, only the fields included in the JSON file will be updated, except in the case of arrays. When updating an array using PUT, all fields in the array are overwritten with the contents of the new array you upload, unless you append the following to your request query string: "append=true".

Toggle Cloak
id1
Example "legacy" PUT request for updating an array

Cloak
id1

This example walks you through the process of properly updating the pixels array of creative ID 503577 using the "legacy" method; in other words, with the "overwrite arrays on PUT" behavior that occurs unless you append the string "append=true" to the query string of your request.

First, let's look at the creative. Note that the pixels array already includes one pixel.

Next, we create the JSON file for adding a new pixel to the creative. In the file, we include both the new pixel that we want to add and the pixel that was already attached to the creative.

If we don't include the existing pixel in the JSON file, our update will delete that pixel from the creative.

Then we make a PUT call to update the creative with the information in the JSON file. Note that the pixels array in the response includes both the new and old pixels.

...

$ curl -bc 'https://api.appnexus.com/plugin?id=13' | jq '.response.plugin.member_availabilities'

[
  {
    "id": 4,
    "is_available": true
  },
  {
    "id": 7,
    "is_available": true
  }
]
    

...

Code Block
title
$ curl -bc -X PUT -d @plugin-update.json 'https://api.appnexus.com/plugin?id=13&append=true' | jq '.response.plugin.member_availabilities'
[
  {
    "is_available": false,
    "id": 4
  },
  {
    "is_available": true,
    "id": 7
  }
]

Meta: What Fields Are Available

In almost all services you can add /meta to the end of the URL and get a list of the fields included in the service. You will also see the "type", such as "int", and whether or not you can sort and filter by that field. For example:

Code Block
$ curl -b cookies 'https://api.appnexus.com/member/meta'

{
  "response": {
    "status": "OK",
    "fields": [
      {
        "name": "id",
        "type": "int",
        "sort_by": false,
        "filter_by": false
      },
      {
        "name": "name",
        "type": "string",
        "sort_by": false,
        "filter_by": false
      },
      {
        "name": "reselling_description",
        "type": "string",
        "sort_by": false,
        "filter_by": false
      },

. . .


JSON Basic Structure

Below are the syntax of the components of a JSON object and what they mean.

...