Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Community,
I want to add Roles to a user in Nprinting via Rest API
Can Somebody tell me the parameters in the BODY, which i have to add.
QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 400 (Bad Request):
{"error":{"code":400,"message":"Malformed parameters in body"}}
Post:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "XXXXXXXXXXXX", BODY "????????????????????????",
HTTPHEADER "Origin" "XXXXXXXXXXXXXX",
HTTPHEADER "Content-Type" "application/json",
HTTPHEADER "X-HTTP-Method-Override" "PUT",
HTTPHEADER "cookie" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; ")
Is there a general way to find the parameters for the bodies? Because I need this also for filters and groups for a user.
Thank you in advance
Aaron
Hi Johan,
I do as you said in the script but there still is one error.
________________________________________________________________________________________
set vUserBody = '{"id":"$(vUserId)","my_group_guid":"6e026b28-58e8-4cbc-b906-30c0050491c4"}';
let vUserBody = replace(vUserBody,'"', chr(34)&chr(34));
let vPostUserULR = 'https://k70svqlikprod:4993/api/v1/users/'&'$(vUserId)/groups';
RestNPPOSTandPUTTestTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPostUserULR)", BODY "$(vUserBody)",
HTTPHEADER "Origin" "XXXXXXXXXXXXXXXXXXXXXXXXXXX",
HTTPHEADER "Content-Type" "application/json",
HTTPHEADER "X-HTTP-Method-Override" "PUT",
HTTPHEADER "cookie" "$(vCookie)");
[post_and_put_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPPOSTandPUTTestTable
WHERE NOT IsNull([__KEY_data]);
DROP TABLE RestNPPOSTandPUTTestTable;
_________________________________________________________________________________________
Is there any mistakes, could you please help show me. thanks in advance.
Johan,
I am still struggling with getting this to work. Is this what you meant?
set vUserGroupBody ='["b5a236e9-b8de-4a74-b92d-000ed15d0ae9","19e6feb1-58ff-412e-bb02-bc0a9c114f8d"]';
let vUserGroupBody = replace(vUserGroupBody,'"', chr(34)&chr(34));
...
WITH CONNECTION( URL "$(vPutUserGroupURL)", BODY "$(vUserGroupBody)",
...
I can get it to work in Postman but when I run it in Qlikview I get the following error.
{"error":{"code":400,"message":"Malformed parameters in body"}}
Thanks
i just got this to work too by updating an existing user's security role .
Try it on an NPrinting user that isn't an administrator. When you work with administrators, it won't work unless you include the administrator roleID in the body as well.
otherwise it looks good.
please show a screenshot of the full error if you can ... need to see every parameter in there and what its resolving too in your environment
Hi Blaise
Can you provide the full syntax.
iam using only user
TIA
The whole lot you can find here:
https://nprintingadventures.com/2019/04/08/nprinting-api-qlik-rest-subroutines/
Can you provide me the sample code for this?