Set

Adds/removes an association between an image and an ad.

To remove an association (unbind an image from an ad), pass an AdImageAssociation structure in which the AdImageHash parameter is omitted or is set to NULL.

Only one image can be associated with an ad: when adding a new association, the old one is removed automatically (however, points are deducted only for adding it).

Restrictions

Attention. The method only supports text and image ads. To work with all types of ads, use the Ads service in version 5 of the API. More about ad types...

Input data

The input data structure in JSON is shown below.

{
   "method": "AdImageAssociation",
   "param": {
      /* AdImageAssociationRequest */
      "Action": (string),
      "AdImageAssociations": [
         {  /* AdImageAssociation */
            "AdID": (long),
            "AdImageHash": (string),
         }
         ...
      ]
   }
}

Parameters are described below.

ParameterDescriptionRequired
AdImageAssociationRequest object
ActionAction: Set.Yes
AdImageAssociationsArray of AdImageAssociation objects (no more than 10,000). Each object contains an association between an image and an ad.Yes
AdImageAssociation object
AdIDThe ad ID.Yes
AdImageHash

Hash of the image.

If the parameter is omitted or NULL, the association between the image and ad is removed.

No

Output data

Attention. An error when adding/removing one of the associations does not cause the entire operation to be canceled, and does not affect the success of adding/removing the other associations.

The output data structure in JSON is shown below.

{
   "data": {
      /* AdImageAssociationResponse */
      "ActionsResult": [
         {  /* AdImageAssociationActionResult */
            "AdID": (long),
            "Errors": [
               {  /* Error */
                  "FaultCode": (int),
                  "FaultString": (string),
                  "FaultDetail": (string)
               }
               ...
            ]
         }
         ...
      ],
   }
}

Parameters are described below.

ParameterDescription
AdImageAssociationResponse object
ActionsResult

Array of AdImageAssociationActionResult objects. Each object corresponds to an item in the AdImageAssociations input array and contains:

  • Just the ad ID, if the association was added/removed successfully.
  • The Errors array, if an error occurred.

The items in the array are in the same order as the objects in the AdImageAssociations input array.

AdImageAssociationActionResult object
AdIDThe ad ID.
ErrorsArray of Error objects with errors that occurred while adding/removing associations.
Error object
FaultCodeError code.
FaultStringTextual message about the error.
FaultDetailDetailed description of the reason for the error.

Examples of input data

Python

{
   'Action': 'Set',
   'AdImageAssociations': [
      {
         # Adding associations
         'AdID': 2571700,
         'AdImageHash': 'c6da811f75221196dd5b1a8ca703344b',
      },
      {
         # Removing associations
         'AdID': 2571745
      },

   ]
}

PHP

array(
   'Action' => 'Set',
   'AdImageAssociations' => array(
      array(
         # Adding associations
         'AdID' => 2571700,
         'AdImageHash' => 'c6da811f75221196dd5b1a8ca703344b'
      ),
      array(
         # Removing associations
         'AdID' => 2571745
      )
   )
)

Perl

{
   'Action' => 'Set',
   'AdImageAssociations' => [
      {
         # Adding associations
         'AdID' => 2571700,
         'AdImageHash' => 'c6da811f75221196dd5b1a8ca703344b'
      },
      {
         # Removing associations
         'AdID' => 2571745
      }
   ]
}