Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Store the data form HttpClientRequest

Avatar

Level 3

Hello, im working on a HttpClientRequest in Adobe Campaign. I've built a javascript node that will handle this. I have a succesfull response that I am able to see as a JSON object when I logInfo.

 

The base of the request (example):

 

var http = new HttpClientRequest("https://blablablac.net/CRM/Report/Test/ViewingDate?ViewingStartDate=2022-08-18T12:00:00&ViewingEndDate=2022-09-01T12:00:00&PageSize=0&PageIndex=0")

var buffer = new MemoryBuffer()
buffer.fromString("1Username1" + ':' + "password123123123123", "iso-8859-1")

http.header["Authorization"] = "Basic " + buffer.toBase64();
http.header["Content-Type"] = "text/xml; charset=utf-8";

http.method = "GET";

http.execute();
var resp = http.response;
var post = JSON.parse(resp.body);

logInfo(resp.body);

 

 

But how to I actually store the data from this response into a Adobe Campaign Schema? I want to do a for loop running through all the rows and then store each of variables from the object into my schema in adobe campaing. Can't find a good example for this.

 

Thanks in advanced,

Martin

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @marting66652718,

 

To store this data from the variable you can first declare an empty column say 'Json Response' (resp) and then use the WRITE function to update data in this column of the temp table of workflow, using a Js code. Now you can run this Write function in the loop for each row. Once the data is inserted in the column for all rows then you can use the 'Update data' activity to insert it in your desired table.
Link to seek more info on Data Oriented API's

My random example based on your case:

_Shubham_Goyal__1-1666335531194.png

 

Js Code (example - I just used some @id as join condition which may vary in your case of Join):

xtk.session.Write(<enrich xtkschema="temp:query" id={id} _key="@id" _operation="update" resp={resp.body}/>);

Or may use SQL function and inserts data in the column of temp table:(example)

    var sql = "UPDATE  "+vars.tableName+" SET sResp= '"+resp.body+"' where <join condition>;
    sqlExec(sql);

Br,

Shubham

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @marting66652718,

 

To store this data from the variable you can first declare an empty column say 'Json Response' (resp) and then use the WRITE function to update data in this column of the temp table of workflow, using a Js code. Now you can run this Write function in the loop for each row. Once the data is inserted in the column for all rows then you can use the 'Update data' activity to insert it in your desired table.
Link to seek more info on Data Oriented API's

My random example based on your case:

_Shubham_Goyal__1-1666335531194.png

 

Js Code (example - I just used some @id as join condition which may vary in your case of Join):

xtk.session.Write(<enrich xtkschema="temp:query" id={id} _key="@id" _operation="update" resp={resp.body}/>);

Or may use SQL function and inserts data in the column of temp table:(example)

    var sql = "UPDATE  "+vars.tableName+" SET sResp= '"+resp.body+"' where <join condition>;
    sqlExec(sql);

Br,

Shubham