Change a curl command to httprequest
Posted: Wed Jan 09, 2019 3:01 am
Here is something very "off topic". I am developing a system that will allow schools to download cataloguing data from a site in Australia. The site has introduced an API with examples given as curl commands. I would like to translate the commands into a single line that can be sent via httprequest() in PB. Can't quite work out how to do it.
Examples from the API integration guide:
Heath check:
curl -i -X GET --url https://api-uat.scisdata.com/checkStatus --basic -u testapi2:abc123
Search:
curl -i -X GET --url 'https://apiuat.
scisdata.com/catalogue/api/search?query=titleSearch%3Adogs%20AND%20publicationYear%3A2015&from=0&size
=20&sort=author&order=asc' -H 'Authorization: Basic dGVzdGFwaTI6YWJjMTIz'
Download MARC records:
curl -X POST -H "Content-Type: application/json" -d '{"identities":["1736952","1692646","1835443"],"fileType":"MARC"}'
https://api-uat.scisdata.com/catalogue/download -H 'Authorization: Basic dGVzdGFwaTI6YWJjMTIz'
Download image:
curl -X POST -H "Content-Type: application/json" -d '{"identities":["1736952","1692646"]}' https://apiuat.
scisdata.com/catalogue/image/download -H 'Authorization: Basic dGVzdGFwaTI6YWJjMTIz' -o testdownload.zip
I was not able to get curl to work as it kept rejecting the https type but I could make example 1 work in a browser.
These commands include authentication - username (testapi2) and password (abc123). Apart from example 1, the others are base-64 encoded.
Results are returned in JSON format.
If anyone can help, I would be grateful.
Thanks.
Examples from the API integration guide:
Heath check:
curl -i -X GET --url https://api-uat.scisdata.com/checkStatus --basic -u testapi2:abc123
Search:
curl -i -X GET --url 'https://apiuat.
scisdata.com/catalogue/api/search?query=titleSearch%3Adogs%20AND%20publicationYear%3A2015&from=0&size
=20&sort=author&order=asc' -H 'Authorization: Basic dGVzdGFwaTI6YWJjMTIz'
Download MARC records:
curl -X POST -H "Content-Type: application/json" -d '{"identities":["1736952","1692646","1835443"],"fileType":"MARC"}'
https://api-uat.scisdata.com/catalogue/download -H 'Authorization: Basic dGVzdGFwaTI6YWJjMTIz'
Download image:
curl -X POST -H "Content-Type: application/json" -d '{"identities":["1736952","1692646"]}' https://apiuat.
scisdata.com/catalogue/image/download -H 'Authorization: Basic dGVzdGFwaTI6YWJjMTIz' -o testdownload.zip
I was not able to get curl to work as it kept rejecting the https type but I could make example 1 work in a browser.
These commands include authentication - username (testapi2) and password (abc123). Apart from example 1, the others are base-64 encoded.
Results are returned in JSON format.
If anyone can help, I would be grateful.
Thanks.