26
Views
8
Comments
Solved
API call gets decoded wrongly and changes : in to %3a
Question
Application Type
Reactive

Hi,

I want to make an API call to AD manager+.

When I set up my API call and test it, the URL is built successfully and I get a positive Response.
This is my API call:

Post:
https://*****/RestAPI/AddUsersToGroup?PRODUCT_NAME=SDP%20AddOn%20Check&domainName=**.local&inputFormat=[%7b%22sAMAccountName%22:%22UserName%22%7d]&addGroup=[%22GroupName%22]&AuthToken=**** 

However, when I want to use the API in my module I always get an error.
In the error log I see that he is translating : in to %3a. 

I have tried converting it in every way I could think of but the error persists.

POST:
https://***/RestAPI/AddUsersToGroup?PRODUCT_NAME=SDP+AddOn+Check&domainName=**.local&inputFormat={"sAMAccountName"%3a"UserName"}&addGroup=GroupName&AuthToken=***

Also I tried adding the parameters in the body, but AD manager+ won't allow it.

I also checked my devtools in chrome. The parameters that are being send are correct.

Do any of you have any tips on how to resolve this?
I've been trying for 2 days now and I'm at the end of my with.




2025-01-15 08-35-04
Vignesh Sekar
Solution

Dear Sarah Vens
inputFormat and addGroup should be arrays of JSON objects, like [{ },]. So, please add the array object [ ]. 

eg :
https://***/RestAPI/AddUsersToGroup?PRODUCT_NAME=SDP+AddOn+Check&domainName=**.local&inputFormat=[{"sAMAccountName"%3a"UserName"}]&addGroup=[GroupName]&AuthToken=*** 

UserImage.jpg
Sarah Vens

In my original request the [ ] is added, seems like it's getting rid of it to when I use the API cal in my program

UserImage.jpg
Sarah Vens

I changed my Inputparameter and groupname like this:

%5b{"sAMAccountName"%3a"accountname"}%5d 

%5b"ACM_CLM2__Women"%5d 


Then it worked! 

thx!

2022-12-30 07-28-09
Navneet Garg

can you provide more details like screenshot of error log and how you are consuming the rest api ?

UserImage.jpg
Sarah Vens

This is how i set up the API.


here is where I consume it:

at this point, this is the SAMAccountName and Group name

This is the error:


2025-01-15 08-35-04
Vignesh Sekar
Solution

Dear Sarah Vens
inputFormat and addGroup should be arrays of JSON objects, like [{ },]. So, please add the array object [ ]. 

eg :
https://***/RestAPI/AddUsersToGroup?PRODUCT_NAME=SDP+AddOn+Check&domainName=**.local&inputFormat=[{"sAMAccountName"%3a"UserName"}]&addGroup=[GroupName]&AuthToken=*** 

UserImage.jpg
Sarah Vens

In my original request the [ ] is added, seems like it's getting rid of it to when I use the API cal in my program

UserImage.jpg
Sarah Vens

I changed my Inputparameter and groupname like this:

%5b{"sAMAccountName"%3a"accountname"}%5d 

%5b"ACM_CLM2__Women"%5d 


Then it worked! 

thx!

2021-11-12 04-59-31
Manikandan Sambasivam

Hi,

have you tried OnBeforeRequest to replace %3a from the query string?

UserImage.jpg
Sarah Vens

I have tried to use the "on before request" on several occasions, but I never seem to get it to work. It always says that my request parameter is: 

 "object reference not set to an instance of an object"

2024-11-07 03-28-42
Stuart Harris
Champion

Hello Sarah,

It is URL encoding the colon; %3a in a URL value is the same as a colon. Though, it is unusual to be passing JSON in a URL query parameter. Normally you would pass it in the body. However, I am not across the API you are calling.

Have a look at the HTML URL Encoding Reference and URL Encode and Decode - Online to see how URLs are encoded.

I hope this helps.

Kind regards,

Stuart

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.