Reputation: 3
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.
Upvotes: 0
Views: 51
Reputation: 369274
&
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
Upvotes: 0
Reputation: 3263
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.
Upvotes: 1