How to pass empty string in endpoint i.e. URL containing '//' in HTTPRequest?

Hi Team,

How can I pass empty string in HTTPRequest endpoint? In postman it works as expected where as UiPath keeps throwing API Error 500.

I have tried using string variable and assign nothing to it. No luck.

Sample endpoint: https://api.myweb.com/api//balance

Thanks…

hi @ByteBreaker ,

Did you actually assign an empty string to the variable?
Eg. Assign strVariable = “” ?

Have you tried assigning strVariable = “”“” with extra double quote marks?

No, it does not work. It ends with quotes in string not null.

@Keegan_Kosasih

You have to use jsonconvert.SerializeObject(jsonstring)

And in json string use null directly and it will be replaced with actual null as you need

Eg: json string would be - {"key1":"value","key2":null}

Cheers

Hi @Anil_G, I am working with endpoint which is string, I am not sure how can I pass JSON string here? Isn’t this solution for body section?

Thanks

@ByteBreaker

This is for body…

Can you show how the endpoint looks in postman

Cheers

Something like this

https://api.abcde.myapp.sh/api/v1/cool//balance?accountIds=123456

@ByteBreaker

Looks like ypu need a // so try //// like this

Cheers

As this is a dynamic value and sometimes I need to pass it empty, the endpoint works without any issue with values. However, once it’s empty, it causes issues. Unfortunately, I cannot hardcode ‘////’ in the endpoint.

Hi @ByteBreaker

Can you please share the error screenshot.

With Value

With null

image

I mocked api for the scenario, I didn’t face any issue passing empty value directly.

you can try this api and let me know if you face the issue. If not maybe the issue related to something else.

@ByteBreaker

You need not hardcode it …if that is working use str.Replace("//","////")

Cheers

Thank @Anil_G for prompt response. It is not working.

@aravindbalineni123 does this api accept values as well? Just to add previous context, this is dynamic URL and sometime null and sometimes values need to be passed.

created just now. pass value test like below:
image

And Also it works when I pass it as a dynamic string.

Just to extend your example, let’s see this is normal endpoint https://7oqeo.wiremockapi.cloud/json/123345/1
(This one should return 200)

and sometime with null this’ll be endpoint
https://7oqeo.wiremockapi.cloud/json//1
(This one should return 404)

Both needs to work (do not have 2 endpoints), so you can define it as a string
strEndPoint = “https://7oqeo.wiremockapi.cloud/json/tmp/1

and try using replace for tmp with nothing and please confirm it works. As First endpoint is not valid one, I can not test in my local.

Appreciate your help Aravind.

Yes. It did work for me.

I used tmp and replaced it with String.Empty

You have defined your end point as //. It will not expect any value between those //.

I tried for my endpoint and still getting:

image

image