Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

DMP Trait via API

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

13-06-2017

Hey Guys,

It's Raza from Bank of Montreal Canada, I am a part of Personalization team here. We are working on something and we need some help. Do anybody have idea about creating a DMP Trait using API. What are prerequisites and other things ?

As of current scenario I have created a tool to generate DMP ruleset and then we copy that ruleset and manually apply that to Adobe Audience Manager(AAM). And In a future iteration of this tool, i'd like to use the AAM APIs within tool to automatically create that rule in AAM once someone clicks the "generate button".  But first we need to investigate how to use the API

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
unnikrishnanv18
Employee

27-06-2017

$base64_code = base64_encode($client_id.":".$client_secret);

$ch = curl_init();

$request_headers = array();

$request_headers[] = 'Content-Type: application/x-www-form-urlencoded';

$request_headers[] = 'Accept: application/json';

$request_headers[] = 'Authorization: Basic '.$base64_code;

$data_to_post = "grant_type=password&username=$username&password=$password";

curl_setopt($ch, CURLOPT_URL, "https://api.demdex.com/oauth/token");

curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);

curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data_to_post);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);

$res = json_decode($result,true);

$access_token = $res['access_token'];

Answers (20)

Answers (20)

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

19-06-2017

Hey,

I have done just like this, still receiving the unauthorized error . Please check the code below (Note : I am running this code from a local HTML file, I have not published anything yet on the http):

$.get( {

    url: 'https://api-beta.demdex.com/oauth/token',

    type: 'POST',

    dataType : "jsonp",

    data: { content: 'grant_type=password&username=<My AudienceManager user name>&password=<My AudienceManager password>' },

    beforeSend : function( xhr ) {

        xhr.setRequestHeader( "Authorization", "Basic <base-64 clientID:clientSecret>" );

        xhr.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );

    },

    success: function( response ) {

  //response

    }

} );

Avatar

Avatar
Validate 1
Level 2
caseyo84500701
Level 2

Likes

17 likes

Total Posts

41 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
caseyo84500701
Level 2

Likes

17 likes

Total Posts

41 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
caseyo84500701
Level 2

13-03-2019

Hi - Curious what Client you are using in the screenshots?

Avatar

Avatar
Springboard
Level 9
Gaurang
Level 9

Likes

144 likes

Total Posts

435 posts

Correct Reply

45 solutions
Top badges earned
Springboard
Validate 100
Validate 50
Validate 25
Validate 10
View profile

Avatar
Springboard
Level 9
Gaurang
Level 9

Likes

144 likes

Total Posts

435 posts

Correct Reply

45 solutions
Top badges earned
Springboard
Validate 100
Validate 50
Validate 25
Validate 10
View profile
Gaurang
Level 9

04-07-2017

Hi Raza,

Did you get a solution to your query? if yes, can you mark a reply as the correct answer. Marking an answer as correct will help other community users as well.

Thanks,

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

27-06-2017

Can you please share the code piece ?

Avatar

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
unnikrishnanv18
Employee

21-06-2017

Hey Razai,

I used a PHP script and was able to get an auth token by setting the mentioned headers. You'll need to check with your dev team to troubleshoot the custom jQuery script by comparing both the requests to identify which parameter or header is missing or wrongly set.

Cheers,

Unni

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

21-06-2017

I feel the problem is with requesting token using Javascript, because when I requested token using JSON client like Postman or ARC(Advance REST Client) It work successfully and I got the JSON response with Access Token. Do you have idea to get Token using Javascript or AJAX ?

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

20-06-2017

I am getting this : XMLHttpRequest cannot load https://api.demdex.com/oauth/token. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 401.

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

20-06-2017

Hi Unni,

I have tried both beta and production site, still facing the same issue. I think this might be a cross domain issue as I am runnin code from a local file

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

20-06-2017

Hey Aman,

I am not using any tool, I am just doing it via Javascript. I feel there is some cross domain issue.

Avatar

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
unnikrishnanv18
Employee

19-06-2017

The auth token request needs to be made against https://api.demdex.com/oauth/token  if the user credentials are for the production account.

Avatar

Avatar
Employee
amanp44838318
Employee

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Employee
amanp44838318
Employee

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
amanp44838318
Employee

19-06-2017

Hi Raza,

Adding to what Devinder shared with you earlier... In case you are using Postman tool for making these requests, here is another thing to keep in mind: we get the following error message when we choose the “Authorization Type” as something other than “No Auth” (assuming that we enter the correct credentials – UN & password for Audience Manager).

So as step 1 in Postman, under "Authorization" tab, you should select "No Auth" as Type. See screenshot below.

1233136_pastedImage_0.png

And then under the tab "Header", for the key "Authorization" the value should be “Basic <base-64 clientID:clientSecret>”

If we select any other Type under tab "Authorization", I see that we get the following response. Is this the error you are getting too?

"{"error":"invalid_grant","error_description":"Bad credentials"}".

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

19-06-2017

Hi Unni,

Please find sample request below :

$.get( {

    url: 'https://api-beta.demdex.com/oauth/token',

    type: 'POST',

  dataType : "jsonp",

    data: { content: 'grant_type=password&username=ABCDEFHG&password=XOXOX1234' },

    beforeSend : function( xhr ) {

        xhr.setRequestHeader( "Authorization", "Basic Ym1vZW5jam1vZWFsLW1bXQ6NjRn3djlrN211nbXQ6NjRcWc5YmhwZmIyYjlmVwbzRtcmJpbaTF0" );

  xhr.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );

    },

    success: function( response ) {

  var responseData = JSON.parse(response);

  console.log(responseData);

    }

} );

Avatar

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Employee
unnikrishnanv18
Employee

Likes

0 likes

Total Posts

4 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
unnikrishnanv18
Employee

19-06-2017

Hello Razai,

Can you please give a sample request with dummy data (please use dummy values for user or account specific information)?

Regards,

Unni

Avatar

Avatar
Boost 1
Level 2
DSRehan
Level 2

Likes

2 likes

Total Posts

6 posts

Correct Reply

3 solutions
Top badges earned
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 1
Level 2
DSRehan
Level 2

Likes

2 likes

Total Posts

6 posts

Correct Reply

3 solutions
Top badges earned
Boost 1
Affirm 3
Affirm 1
View profile
DSRehan
Level 2

16-06-2017

Hi Raza,

You will need to generate an access_token to make API requests. You will need to make an API request to request the access_token.

I am pasting the screenshots below from my demo setup to show how the call should look like:

Header Configuration:
1231241_pastedImage_0.png

Body Configuration:

1231242_pastedImage_1.png

The most important part that people tend to miss out on is encoding the Client ID & Secret to Base64 string.

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

16-06-2017

Hi Gaurang,

I am facing authorization issue while using this code, do you have any idea how to setup authorization as given in this link ? I have Client ID and Client secret

Avatar

Avatar
Springboard
Level 9
Gaurang
Level 9

Likes

144 likes

Total Posts

435 posts

Correct Reply

45 solutions
Top badges earned
Springboard
Validate 100
Validate 50
Validate 25
Validate 10
View profile

Avatar
Springboard
Level 9
Gaurang
Level 9

Likes

144 likes

Total Posts

435 posts

Correct Reply

45 solutions
Top badges earned
Springboard
Validate 100
Validate 50
Validate 25
Validate 10
View profile
Gaurang
Level 9

15-06-2017

Hey Raza,

Your code seems to be fine while using the AAM traits API. Were you able to solve your use case?

Best,

Gaurang

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

13-06-2017

Thank you Parit hoping great answers in new community as well

Avatar

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
razai22062698
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
razai22062698
Level 1

13-06-2017

Hey, Thank you so much Dev I already checked these links and they are really helpful. I am working on a javascript to create DMP trait in AAM and below is so far what I have created, can you please have look and suggest.

var Data = '[{ "pid": 0, "name": "TestData", "description": "TestData", "integrationCode": "TestData", "comments": "TestData", "traitType": "TestData", "status": "TestData", "dataSourceId": 0, "folderId": 0, "traitRule": "TestData", "type": 0, "categoryId": 0, "crUID": 0, "upUID": 0, "createTime": 0, "updateTime": 0 }]';

    var xhttp = new XMLHttpRequest();

    xhttp.open("POST", "https://api.demdex.com/v1/traits/", false);

    xhttp.setRequestHeader("Content-type", "application/json");

    xhttp.send(Data);

    var response = JSON.parse(xhttp.responseText);

console.log(xhttp.status);
console.log(xhttp.statusText);
console.log(response);

Avatar

Avatar
Boost 1
Level 2
DSRehan
Level 2

Likes

2 likes

Total Posts

6 posts

Correct Reply

3 solutions
Top badges earned
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 1
Level 2
DSRehan
Level 2

Likes

2 likes

Total Posts

6 posts

Correct Reply

3 solutions
Top badges earned
Boost 1
Affirm 3
Affirm 1
View profile
DSRehan
Level 2

13-06-2017

Hi Raza,

Here's the link to documentation for Audience Manager's REST APIs​.

Trait API Methods​ have been rewritten with Swagger.

Hope this helps.

Regards,

Devinder Rehan

Avatar

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

93 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

93 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
ParitMittal
Level 10

13-06-2017

Hi Raza,

This query seems to be more related to Adobe Audience Manager . Hence moving the query to Audience Manager Community.

Regards

Parit