keebOo
keebOo

Reputation: 81

-- Curl, terminal version, send POST and GET data at same time: how to?

(new user can't post link, so I strip all http:// from every link in the example)

I have to send an associative array to a webservice (php), via curl terminal shell.

This service is not managed by me, and they ask to me to point to a particular php page and send my results via POST.

The page is something like: www.domain.com/ws.php?authCode=xxx&action=yyy&id=zzz

WRONG WAY

curl -d "@filename_with_all_dataArray.txt" www.domain.com/ws.php?authCode=xxx&action=yyy&id=zzz

or

curl -d "value[0][0]=123&value[0][1]=234&value[1][0]=123&value[1][2]=234" www.domain.com/ws.php?authCode=xxx&action=yyy&id=zzz

or

curl -X POST -d "@filename.txt" www.domain.com/ws.php?authCode=xxx&action=yyy&id=zzz

or

curl -d "value[0][0]=123&value[0][1]=234&value[1][0]=123&value[1][2]=234" -G -d "authCode=xxx&action=yyy&id=zzz" www.domain.com/ws.php

... and all the other combination that I made. ;)

I try also with a local php page that answers dumping out the values (POST and GET), but seems that it's possible to have the array via POST and only the first GET from the url (not the other after the first one)

Any suggestions/solutions?

Upvotes: 0

Views: 2825

Answers (1)

flesk
flesk

Reputation: 7579

The problem is that you haven't quoted the url. It's not a problem with a single get parameter, but when you use several you use '&' which has special meaning in shells. In unix shells it's used to run a command in the background. I use it every day, but it didn't dawn on me until after having slept on it.

Upvotes: 1

Related Questions