Issue while sending Delete On Session request

I am trying to send one Delete request. In the url i am passing a parameter as a dictionary but in the log the curly brackets of dictionary converting into %7B and double quotes converting into %20.
for ex.
${x}= {‘countryId’: ‘64’, ‘from’: 22330581, ‘to’: 22330586}

${req3}= catenate SEPARATOR= /a/b/c? token=${token} &number-range-list=${x}&customer-service-id=abc

${response}= Delete On Session mysession ${req3} headers=${header}

log ${response}

it gives response in logfile as -
DELETE Response : url=https://10.111.14.133:83767/a/b/c?token=NzE1NDlkNTMwOWUxMWVlY2M4MjM4YTgyYzU=&number-range-list=%7B’countryId’:%20’64’,%20’from’:%2022330581,%20’to’:%2022330586%7D&customer-service-id=abc

so as we can see {‘countryId’: ‘64’, ‘from’: 22330581, ‘to’: 22330586} is converting to %7B’countryId’:%20’64’,%20’from’:%2022330581,%20’to’:%2022330586%7D

so how to deal with this condition. Any suggestions is appreciated . Thanks in advance

Hi Anup,

Because you put the variable ${x} into the URL it’s been urlencoded, the %20 is not a double quote (that would be %22) but a space.

if you don’t want the url encoding, perhaps removing the spaces would be enough to stop that happening automatically:

from this:

${x}=    {‘countryId’: ‘64’, ‘from’: 22330581, ‘to’: 22330586}

to this

${x}=    {‘countryId’:‘64’,‘from’:22330581,‘to’:22330586}

It shouldn’t be an issue though the web server should know how to url decode the value.

Hope this helps

Dave.

Hi Dave,
Thanks for your response.
I removed the space and now %20 is not appearing but the curly brackets is encoded to %7B. But i dont want %7B in my request URL, i want curly brackets in my url.

thanks,
Anup

Hi Anup,

I replicated the issue with this little test case I created:

*** Settings ***
Library    RequestsLibrary

*** Variables ***
${x}= 		{'countryId':'64','from':22330581,'to':22330586}
${token}=	NzE1NDlkNTMwOWUxMWVlY2M4MjM4YTgyYzU


*** Test Cases ***
Anup
	Create Session    mysession  http://www.google.com

	Log    ${x}
	${req3}= 	catenate 	SEPARATOR= 	/a/b/c? 	token=${token} 	&number-range-list=${x}&customer-service-id=abc
	Log    ${req3}
	# ${req3}= 	Set Variable    /a/b/c?token=${token}&number-range-list=${x}&customer-service-id=abc
	Log    ${req3}
	${response}= 	Get On Session 	mysession 	${req3}
	log ${response}

Unfortunately I don’t know what the solution is, but I can confirm it’s the “xxx On Session” (e.g. Delete On Session / Get On Session) call that’s doing the url encoding. I just couldn’t find anywhere in the documentation that shows how to stop this.

Maybe there is a ReqiestsLibibrary expert out there thta knows what to do?

Dave.