Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I’m struggling with a strange behavior when using variables in the REST Connector URL with the GET method.
What works
set vURL=https://mktorest.com/bulk/v1/leads/export/abc123/file.json;
LIB CONNECT TO 'Marketo File';
RestConnectorMasterTable:
SQL SELECT
"company",
"email",
"firstName",
"lastName"
FROM CSV (header on, delimiter ",", quote """") "CSV_source"
WITH CONNECTION (
URL "$(vURL)"
);
What does NOT work
let vExportID='abc123';
set vURL=https://mktorest.com/bulk/v1/leads/export/$(vExportID)/file.json;
TRACE vURL: $(vURL);
LIB CONNECT TO 'Marketo File';
RestConnectorMasterTable:
SQL SELECT
"company",
"email",
"firstName",
"lastName"
FROM CSV (header on, delimiter ",", quote """") "CSV_source"
WITH CONNECTION (
URL "$(vURL)"
);
Is this a known limitation or quirk of the Qlik REST Connector with GET request?
Thanks in advance!
Hmm, if I understand it right, maybe at the time you are doing the GET automatically, the file is not ready yet. Is that a possibility? If so, is there an endpoint to check if the file is ready to get?
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Hi @ylchuang ,
Try this:
SET vExportID = 'abc123';
LET vURL = 'https://mktorest.com/bulk/v1/leads/export/$(vExportID)/file.json';
Explanation:
Use SET for static values. Use single quotes when the values are strings. For numeric values you don't need single quotes.
Use LET when you need to process something before assign the value to the variable. In your case, vURL, you are adding the vExportID to a string value.
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Thanks for the suggestion.
It does work if vExportID is static, but actually vExportID is dynamic from a previous table. That's why I used LET.
I tried below combinations and sadly none of them worked.
They work in POST method though.
Both LETs >> does not work
Let vExportID = peek('exportId',0,'result');
Let vURL = 'https://mktorest.com/bulk/v1/leads/export/$(vExportID)/file.json';
LET for dynamic vExportID, SET for vURL >> does not work
Let vExportID = peek('exportId',0,'result');
SET vURL = 'https://mktorest.com/bulk/v1/leads/export/$(vExportID)/file.json';
Using LET in both is the correct approach.
I believe the problem is something else.
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Thanks so much for checking. Below is when using both LETs
Error Message
The following error occurred:
The remote server returned an error: (404) Not Found.
The error occurred here:
RestConnectorMasterTable:
SQL SELECT
"company",
"email",
"firstName",
"lastName"
FROM CSV (header on, delimiter ",", quote """") "CSV_source"
WITH CONNECTION (
URL "https://mktorest.com/bulk/v1/leads/export/1468a515-d55d-4042-9aa6-b354e44c6aee/file.json",
HTTPHEADER "Authorization" "Bearer $(vToken)"
);If I type in the same URL as string, it works without issue.
This URL is coming from variable vURL.
REST API Data Connection Settings
GET as the last step
According to Marketo documentation, first we need to POST: create.json > then POST: enqueue.json > and after the file is created, GET: file.json.
Unfortunately I don't have a public endpoint for testing. But I will check our team.
Hmm, if I understand it right, maybe at the time you are doing the GET automatically, the file is not ready yet. Is that a possibility? If so, is there an endpoint to check if the file is ready to get?
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
I thought so at first as well, so I tested using following steps:
1. Confirm file is ready
I copied and pasted the URL as string directly into URL "https://...." and then reload. The file can be read without issue.
2. Store confirmed URL as text in a table and then assign vExportID to value in this table.
This ensures vExportID is not using a newly generated id from the previous loading script, but is using this confirmed ExportID that has file ready.
This is also done within a few minutes, so the file is not expired.
[tbl_ExportID]:
NoConcatenate Load * Inline [
ID
1468a515-d55d-4042-9aa6-b354e44c6aee
];
Let vExport = peek('ID',0,'tbl_ExportID');
Let vURL = 'https://mktorest.com/bulk/v1/leads/export/$(vExportID)/file.json';
3. Reload > Same error message
After hitting reload, the same error message appears.
It seems GET: URL cannot handle variable that is not static string.
The following error occurred:
The remote server returned an error: (404) Not Found.
In this last version you sent, the variable names are not matching:
Let vExport = peek('ID',0,'tbl_ExportID');
Should be
Let vExportID = peek('ID',0,'tbl_ExportID');
Can you please double check?
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Sorry... typo here, but the actual script is using
Let vExportID = peek('ID',0,'tbl_ExportID');
If I understood correctly you are not using SET because you need it as a dynamic expression.
If that is the case, just use two variables.. first with LET and then define SET from LET , and pass the SET one as a parameter.