Expand my Community achievements bar.

SOLVED

Returning a linked field via API?

Avatar

Level 2

Hi all,

Is there a way to pull data back via API from a linked field?  We are attempting to pull back data from the subscriptions and services fields attached to our recipient data to enrich/update our internal database with the members current subscriptions.

The problem is that the API won’t allow us to select anything from the linked tables, nor to select the values of the FK (foreign key).

So, even though, for example, “service/@name” looks like an attribute and you can select it in the client, from the API we just get an error that the “@name” attribute doesn’t exist.

Can anyone with API knowledge help? We are able to create a CSV export from Campaign of this exact data but cannot through the API

1 Accepted Solution

Avatar

Correct answer by
Level 10

Scott Gaulin wrote...

Thanks for the reply Amit.

We are using version v6.1 and do not have AEM. The developer is using SOAP so could you expand on how to create a custom method to return those values? We'd certainly appreciate it.

 

Best,

 

Scott

 

for your use case you need not to write a cutsom method it's already available in querydef:

use the following as  soap body:

<?xml version='1.0' encoding='ISO-8859-1'?> <SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='http://xml.apache.org/xml-soap' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> <SOAP-ENV:Body> <ExecuteQuery xmlns='urn:xtk:queryDef' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> <__sessiontoken> //put your session token recived from logon method </__sessiontoken> <entity xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'> //change line count to limit your results <queryDef operation="select" lineCount="200" startLine="0" schema="nms:subscription" xtkschema="xtk:queryDef"> <select> <node expr="[recipient/@email]"/> <node expr="[recipient/@lastName]"/> <node expr="[service/@name]"/> </select> <where> <condition expr="[service/@name] != ''"/>//chnage this as per you requirement </where> </queryDef> </entity> </ExecuteQuery> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Url will be : https://<server name>/nl/jsp/soaprouter.jsp

Soap header will have

SOAPAction  :- xtk:queryDef#ExecuteQuery

 

Regards,

Amit

View solution in original post

4 Replies

Avatar

Level 10

Scott Gaulin wrote...

Hi all,

Is there a way to pull data back via API from a linked field?  We are attempting to pull back data from the subscriptions and services fields attached to our recipient data to enrich/update our internal database with the members current subscriptions.

The problem is that the API won’t allow us to select anything from the linked tables, nor to select the values of the FK (foreign key).

So, even though, for example, “service/@name” looks like an attribute and you can select it in the client, from the API we just get an error that the “@name” attribute doesn’t exist.

Can anyone with API knowledge help? We are able to create a CSV export from Campaign of this exact data but cannot through the API

 

Hi Scott,

which version are you using? where do you need this information i.e. in third party websites etc? if you are using v6 then you can rely on following:

1. Create a custom soap method to return you required values

2. If you are using AEM then write custom extensions.

3. inside campaign use querydef and use [service/@name] to get the value.

Regards,

Amit

Avatar

Level 2

Thanks for the reply Amit.

We are using version v6.1 and do not have AEM. The developer is using SOAP so could you expand on how to create a custom method to return those values? We'd certainly appreciate it.

 

Best,

 

Scott

Avatar

Correct answer by
Level 10

Scott Gaulin wrote...

Thanks for the reply Amit.

We are using version v6.1 and do not have AEM. The developer is using SOAP so could you expand on how to create a custom method to return those values? We'd certainly appreciate it.

 

Best,

 

Scott

 

for your use case you need not to write a cutsom method it's already available in querydef:

use the following as  soap body:

<?xml version='1.0' encoding='ISO-8859-1'?> <SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='http://xml.apache.org/xml-soap' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> <SOAP-ENV:Body> <ExecuteQuery xmlns='urn:xtk:queryDef' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> <__sessiontoken> //put your session token recived from logon method </__sessiontoken> <entity xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'> //change line count to limit your results <queryDef operation="select" lineCount="200" startLine="0" schema="nms:subscription" xtkschema="xtk:queryDef"> <select> <node expr="[recipient/@email]"/> <node expr="[recipient/@lastName]"/> <node expr="[service/@name]"/> </select> <where> <condition expr="[service/@name] != ''"/>//chnage this as per you requirement </where> </queryDef> </entity> </ExecuteQuery> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Url will be : https://<server name>/nl/jsp/soaprouter.jsp

Soap header will have

SOAPAction  :- xtk:queryDef#ExecuteQuery

 

Regards,

Amit

Avatar

Level 2

Thank you Amit! Our developer was successful in pulling the needed data using your solution.

Best,

Scott