Follow

How to edit existing data via API?

Time to read: 5 min

topic.pngThe article covers the following topics:

General Info

First of all, to get started with API, you need to find your API-key. To do it, just navigate to 'Users' Tab - > 'Users management' -> 'User edit page':

Screenshot_36.png

 import.png Only the General manager has permission to get the 'User edit page'. 

Next thing you need is API URL, you can find it in 'Settings' Tab -> 'Settings' -> 'Tracking domains' -> 'URLs' section:

Markup_2020-06-16_at_17.55.35.png

click__1_.pngFind out more about where you can find your/Affiliate's API-key and API URL here

API Request Structure: GET/POST + api domain + path + ? + api-key=189471975956279174174.

It should be noted that header content-type - application/x-www-form-urlencoded is used on an ongoing basis, and content-type - multipart/form-data is used for uploading files (logo, creative files). 

How to edit existing data? 

In case you want to change some existing data, you need to use the editing method and rewrite your POST API call with all old values and new changed values. When updating existing data, the body must include the original schema definition and the new fields you are adding.

import.pngWhen you want to change the data, it is very important to re-specify all the old values; otherwise, all the existing values automatically will have a null value (deleted), and you will lose the important information. 

curl --location --request POST 'https://api-rocketcompany.affise.com/3.0/admin/offer' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'api-key: bf09c801ff9b95b14ac8e17d6e4904b6' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'title=OFFER WITH Targeting groups' \
--data-urlencode 'advertiser=5e39279bac611cda7e5765ab' \
--data-urlencode 'url=https://track.gjane.com/hc/click?afclick={clickid}&afpid={pid}&afoffer={offer_id}' \
--data-urlencode 'targeting[0][country][allow][]=RU' \
--data-urlencode 'targeting[0][device_type][]=mobile' \
--data-urlencode 'targeting[0][connection][]=cellular' \
--data-urlencode 'targeting[0][sub][allow][1][]=qwerty' \
--data-urlencode 'targeting[0][os][allow][0][name]=iOS' \
--data-urlencode 'targeting[0][os][allow][0][comparison]=EQ' \
--data-urlencode 'targeting[0][os][allow][0][version]=12.0' \
--data-urlencode 'targeting[0][isp][allow][RU][0]=Mts' \
--data-urlencode 'targeting[0][ip][allow][0]=11.12.13.0-17.18.19.22' \
--data-urlencode 'targeting[0][browser][allow][0]=Yandex.Browser for iOS' \
--data-urlencode 'targeting[0][brand][deny][0]=Smartbook Entertainment' \
--data-urlencode 'targeting[0][connection][0]=wi-fi' \
--data-urlencode 'targeting[0][block_proxy]=1' \
--data-urlencode 'targeting[0][url]=http://test-url.com' \
--data-urlencode 'targeting[1][country][allow][]=US' \
--data-urlencode 'targeting[1][device_type][]=desktop' \
--data-urlencode 'targeting[1][connection][]=wi-fi' \
--data-urlencode 'targeting[1][affiliate_id][]=2' \
--data-urlencode 'targeting[1][sub][deny][2][]=qwerty213' \
--data-urlencode 'targeting[1][sub][deny_groups][1][4]=' \
--data-urlencode 'targeting[1][sub][deny_groups][0][1]=fu' \
--data-urlencode 'targeting[1][sub][deny_groups][0][2]=lu'
curl --location --request POST 'https://api-rocketcompany.affise.com/3.0/admin/offer/132966' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'api-key: bf09c801ff9b95b14ac8e17d6e4904b6' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'title=OFFER WITH Targeting groups' \
--data-urlencode 'advertiser=5e39279bac611cda7e5765ab' \
--data-urlencode 'url=https://track.gjane.com/hc/click?afclick={clickid}&afpid={pid}&afoffer={offer_id}' \
--data-urlencode 'targeting[0][country][allow][]=BY' \
--data-urlencode 'targeting[0][device_type][]=desktop' \
--data-urlencode 'targeting[0][connection][]=wi-fi' \
--data-urlencode 'targeting[0][sub][allow][1][]=qwerty' \
--data-urlencode 'targeting[0][os][allow][0][name]=iOS' \
--data-urlencode 'targeting[0][os][allow][0][comparison]=EQ' \
--data-urlencode 'targeting[0][os][allow][0][version]=12.0' \
--data-urlencode 'targeting[0][isp][allow][RU][0]=Mts' \
--data-urlencode 'targeting[0][ip][allow][0]=11.12.13.0-17.18.19.22' \
--data-urlencode 'targeting[0][browser][allow][0]=Yandex.Browser for iOS' \
--data-urlencode 'targeting[0][brand][deny][0]=Smartbook Entertainment' \
--data-urlencode 'targeting[0][connection][0]=wi-fi' \
--data-urlencode 'targeting[0][block_proxy]=1' \
--data-urlencode 'targeting[0][url]=http://test-url.com' \
--data-urlencode 'targeting[1][country][allow][]=US' \
--data-urlencode 'targeting[1][device_type][]=desktop' \
--data-urlencode 'targeting[1][connection][]=wi-fi' \
--data-urlencode 'targeting[1][affiliate_id][]=2' \
--data-urlencode 'targeting[1][sub][deny][2][]=qwerty213' \
--data-urlencode 'targeting[1][sub][deny_groups][1][4]=' \
--data-urlencode 'targeting[1][sub][deny_groups][0][1]=fu' \
--data-urlencode 'targeting[1][sub][deny_groups][0][2]=lu'
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.