Edit the API response

Avatar

Avatar
Give Back
Level 2
jeromen49554524
Level 2

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 3
Boost 1
View profile

Avatar
Give Back
Level 2
jeromen49554524
Level 2

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 3
Boost 1
View profile
jeromen49554524
Level 2

26-06-2019

We are looking to optimize our integration with the Adobe Campaign API and are wondering if we are able to change the response Adobe Campaign is giving on certain calls. I.e. for retrieving a session token, the response is quite big and bloated. Is there a way to trim this down and only give back the session token?

Thanks!

Replies

Avatar

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

516 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

516 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile
wodnicki
MVP

26-06-2019

Hi,

Create your own API using a schema def, proxied to the desired API via js/jsapi.

Thanks

-Jon

Avatar

Avatar
Give Back
Level 2
jeromen49554524
Level 2

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 3
Boost 1
View profile

Avatar
Give Back
Level 2
jeromen49554524
Level 2

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 3
Boost 1
View profile
jeromen49554524
Level 2

27-06-2019

Thanks! That does make a lot of sense.

In this case I would like to do it for the initial call for retrieving a session token. Can I get the .js somewhere, so I can repurpose it and don't need to write everything from scratch?

Avatar

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

516 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

516 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile
wodnicki
MVP

27-06-2019

Hi,

For schema cus:api, use this js:

function cus_api_Logon (login, password, parameters) {

    return xtk.session.Logon.apply(this, arguments).sessionToken;

}

Thanks,

-Jon

Avatar

Avatar
Give Back
Level 2
jeromen49554524
Level 2

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 3
Boost 1
View profile

Avatar
Give Back
Level 2
jeromen49554524
Level 2

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 3
Boost 1
View profile
jeromen49554524
Level 2

28-06-2019

Thanks Jon,

So I've done the following:

  • Copied the xtk:session schema and made a cus:cusomtSession one
  • Changed the logon method name to cus_api_Logon
  • Added the library attribute cus:api.js in the method
  • Copy/pasted the javascript code in the newly made cus:api.js

Now I'm getting the following error:

   <faultstring xsi:type='xsd:string'>SOP-330011 Error while executing the method 'cus_api_Logon' of service 'cus:customSession'.</faultstring>

            <detail xsi:type='xsd:string'>JST-310001 Error while evaluating a JavaScript code, line 1: (void 0) is not a function.</detail>

Even if I just put a log in the js file it doesn't seem to work. Anything I missed?

Thanks!

Avatar

Avatar
Boost 5
Level 3
geoffreyl240454
Level 3

Likes

27 likes

Total Posts

47 posts

Correct reply

6 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Level 3
geoffreyl240454
Level 3

Likes

27 likes

Total Posts

47 posts

Correct reply

6 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
geoffreyl240454
Level 3

08-08-2019

Hi jeromen49554524​,

The name of the function must be "namespace_name_methodName". In your case, if your schema is named "cus:cusomtSession", the JavaScript function must be named "cus_cusomtSession_Logon".

Example:

- Schema namespace: cus

- Schema name: example

- Method name in the schema: getToken

- JavaScript function name: cus_example_getToken

Hope that will help you,

Best Regards,

Geoffrey.