Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik_Developer1
Contributor II
Contributor II

issue with REST Api post method throwing bad request.

Hi All,

iam trying to post the below records to destination through the rest api ,

[
{

"dcId": 770,
"year": 2022,
"month": 1,
"serviceName": "VSI Silver",
"networkName": "ESF",
"demandAttr": {
"OSI": 236.795
}
}
]

 

 

the test connection is working fine with above body ,but using    with  ''with connection'" its throwing error like bad request,

any one please help on below code is there any error in below code

thanks

 

 

LET vRequestBody ='[';
LET vRequestBody ='{';
Let vRequestBody = vRequestBody&'"dcId":778,';
Let vRequestBody = vRequestBody&'"year":2022,';
Let vRequestBody = vRequestBody&'"month":1,';
Let vRequestBody = vRequestBody&'"serviceName":"VSI Silver",';
Let vRequestBody = vRequestBody&'"networkName":"ESF",';
Let vRequestBody = vRequestBody&'"demandAttr":{';
Let vRequestBody = vRequestBody&'"OSI":236.795';
Let vRequestBody = vRequestBody&'}';
Let vRequestBody = vRequestBody&'}';
Let vRequestBody = vRequestBody&']';
let vRequestBody = replace(vRequestBody,'"', chr(34)&chr(34));

LIB CONNECT TO 'REST_helius_PostMethod';


RestConnectorMasterTable:
SQL SELECT

"__KEY_root",
(SELECT
"dcId",
"year",
"month",
"serviceName",
"networkName",
"__KEY_data",
"__FK_data",
(SELECT
"OSI",
"__KEY_demandAttr",
"__FK_demandAttr"
FROM "demandAttr" PK "__KEY_demandAttr" FK "__FK_demandAttr")
FROM "data" PK "__KEY_data" FK "__FK_data"
)
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(
BODY "$(vRequestBody)"
);

7 Replies
Eugene_Sleator
Support
Support

Refer to this article

Qlik Rest Connector Post Method (into the script) 

 

 

 

 

Qlik_Developer1
Contributor II
Contributor II
Author

same script but its not working ,but the test connection is working fine with below post body

 

[
{

"dcId": 770,
"year": 2022,
"month": 1,
"serviceName": "VSI Silver",
"networkName": "ESF",
"demandAttr": {
"OSI": 236.795
}
}
]

 

Eugene_Sleator
Support
Support

Can you post your error 

Qlik_Developer1
Contributor II
Contributor II
Author

chaganti26_0-1630989743025.pngchaganti26_1-1630989793315.png

here is the error message while loading

Qlik_Developer1
Contributor II
Contributor II
Author

@any help on this Qlikadmin team

NadiaB
Support
Support

Hi @Qlik_Developer1 

 

By any chance have you seen this already ??

https://community.qlik.com/t5/New-to-Qlik-Sense/Qlik-Rest-Connector-Post-Method-into-the-script/td-p...

Hope it helps!

Don't forget to mark as "Solution Accepted" the comment that resolves the question/issue. #ngm
Eugene_Sleator
Support
Support

This may also be of help, make sure there is no URL encoding used in the connector config 

https://community.qlik.com/t5/Support-Updates-Blog/Error-400-Bad-Request-returned-for-URL-with-speci...