curl / Mailing Lists / curl-users / Single Mail

curl-users

Re: Translating cUrl command into REST

From: Ray Satiro via curl-users <curl-users_at_cool.haxx.se>
Date: Wed, 16 Nov 2016 00:48:19 -0500

On 11/14/2016 7:00 AM, Hernâni Fernandes wrote:
>
> I'm currently in a project where I'm trying to use Qualtrics API to
> import a list of contacts (which is in a JSON file). The only way I'm
> able to succeed in this call is by using cURL with a command as follows:
>
> curl -X Post -H "X-API-Token: myToken" -H "Content-Type:
> multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
> -F
> "contacts=@c:/Users/hff/desktop/contactsToImport.json;type=application/json"
> -D "mailingListId=ML_3mDlcskNrepn0S9"
> "https://eu.qualtrics.com/API/v3/mailinglists/ML-3mDlcskNrepn0S9/contactimports"
>
> I need to use this API via a REST request (not through cURL) though -
> and I can't seem to figure out what is the result (as in, what is the
> REST request that comest out) of this cURL command.

I don't know why you are sending your own boundary header, that doesn't
make any sense here, omit it. Also review the qualtrics documentation
for this command [1]. You can run curl in verbose mode (curl -v) to see
what headers it sends. Basically curl is POSTing (ie REST create) as
multipart/form-data with the one and only part name="contacts"
containing the json file c:/Users/hff/desktop/contactsToImport.json as
content type application/json. Consult the documentation for the tool
you will be using to learn how to do that.

[1]: https://api.qualtrics.com/docs/create-contacts-import

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-users
FAQ: https://curl.haxx.se/docs/faq.html
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-11-16