Question

I'm using pythons in backend and i like to get some data through URL, simply i can say as through REST. My URL works with single param but fails for two params. Please refer below two URL

Single param:

curl -XPUT -HContent-type:text/plain --data "stuff:morestuff"  <URL>?attr1=testvalue

Two param:

curl -XPUT -HContent-type:text/plain --data "stuff:morestuff"  <URL>?attr1=testvalue&attr2=133

I cross verify that, python code is correct.

Was it helpful?

Solution

you may missed out escape key() after & in the URL, try this one.... i hope this will work

curl -XPUT -HContent-type:text/plain --data "stuff:morestuff"  <URL>?attr1=testvalue\&attr2=133

I faced similar problem, it works. make an try and let me know.

OTHER TIPS

& is interpreted by shell. Strings before and after & are treated as separated command. (BTW, & means run in background in shell).

To prevent that, quote the url:

curl -XPUT -HContent-type:text/plain --data "stuff:morestuff" "<url>?attr1=testvalue&attr2=133"

or

curl -XPUT -HContent-type:text/plain --data "stuff:morestuff" '<url>?attr1=testvalue&attr2=133'

or escape the &:

curl -XPUT -HContent-type:text/plain --data "stuff:morestuff" <url>?attr1=testvalue\&attr2=133
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top