Get request - formatting JSON file - api

I want to start a curl request from a batch file. The result is a unformatted data file.
call curl --request GET --url "http:*****" --header "Accept: */*"
--header "Accept-Encoding: gzip, deflate" --header "Authorization:****" --header "Cache-Control: no-cache" --header "Connection: keep-alive" --header "Content-Type: application/json" >****.json
Know anyone a solution to get a format json data file.
Thanks in advance!

May I ask question,
What OS you are using for curl request?
Depending on the OS, there are many ways that you can reformat the json response.
If it is Ubuntu, you can install "json_reformat" library and use in curl command
i.e.
curl ..the url ... | json_reformat

Related

curl GET json request for more than 100 items

I am trying to send a GET request for 300 items.
I am able to get 100 items with this request
curl --request GET --url "https://**/items?limit=100" --header "Content-Type:application/json" >test.json
with the following requests i am able to get 100 items for each page
curl --request GET --url "https://**/items?page=1&limit=100" --header "Content-Type:application/json" >test.json
curl --request GET --url "https://**/items?page=2&limit=100" --header "Content-Type:application/json" >test.json
curl --request GET --url "https://**/items?page=3&limit=100" --header "Content-Type:application/json" >test.json
Is there a solution to get all 300 items in one request and safe them in one file?
You can use either of the following:
curl --request GET --url "https://**/items?page={1,2,3}&limit=100" --header "Content-Type:application/json" >test.json
curl --request GET --url "https://**/items?page=[1-3]&limit=100" --header "Content-Type:application/json" >test.json

Seting a Curl command to run in a Zapier Webhook

I'm trying to find the way to run cURL query in Zapier webhook, but I can't seem to figure it out. How would I enter this in the Webhook?
curl 'https://api.com/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://api.com' -H 'access_token: <my token>' --data-binary '{"query":"{\n booking(booking_id: \"11111\"){\n user{\n name\n }\n body\n }\n}\n"}' --compressed
This is the error I'm getting:
You need to put query in the left box under Query String Params. query is the key, the value is {\n booking(book.... You don't need quotes, either.

google gcm raw_data (payload encryption) , push event not received

I need some help because i never receive push event in my serviceworker after payload encryption.
First case without payload encrypted
In this case, I receive push event in service worker:
Request is :
curl -s --header "Authorization: key=MY_KEY" --header "Content-Type: application/json" --header "TTL:86400" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"elmll0-ynBY:APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\"],\"delay_while_idle\":false,\"collapse_key\":\"hipush-notification\",\"time_to_live\":86400}"
Google response is :
{"multicast_id":5772871775830750210,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1465913797471899%f4d428f3bf364ddd"}]}
Second test, with encrypted raw_data
I never receive push event:
- Request is :
curl -s --header "Authorization: key=MY_KEY" --header "Content-Type: application/json" --header "TTL:86400" --header "Encryption: salt=KYw1fpU-Dg4w1qFcrPY3rQ" --header "Crypto-Key: dh=BOwb4OiwboYRrbhhXh056xFZ8pk8kfQR27Gmu3EdYPG9DkLoKRqA_d4Z_TbT2VYMfHVkGS-dY45rZ8tAimqSWrk" --header "Content-Encoding:aesgcm" https://android.googleapis.com/gcm/send --header "Content-Length: 363" -d "{\"registration_ids\":[\"elmll0-ynBY:APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\"],\"delay_while_idle\":false,\"collapse_key\":\"hipush-notification\",\"time_to_live\":86400,\"raw_data\":\"rXJHqmhxmTde+297wtb3Tpj5Lq5C8cd2eYW5qTBoC3huGVTOPog6+I2Y6wQEYqP1QIAvUA0NFtYC7Zr\/iCR1sGcu\"}"
Google response is :
{"multicast_id":7840093467258640262,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1465913901129815%f4d428f3bf364ddd"}]}
I got same response with success. My chrome is in version 51.
Can someone explain me where is my error ?
Best regards,
Mehdi
Which language are you using? You could use one of the libraries here https://github.com/web-push-libs (Node.js, PHP, Python, Java currently supported), which have already fixed the problem for you.

Why can't I enable or disable my GlassFish application through the REST API?

When I submit a REST request, EG: (included auth is for admin/adminadmin)
curl -ik -X POST -H "Accept: application/json"
-H "Authorization: Basic YWRtaW46YWRtaW5hZG1pbg=="
https://localhost:4848/management/domain/applications/application/MyApp/enable
GlassFish just rejects the request:
HTTP/1.1 400 Bad Request
Content-Length: 0
Date: Wed, 17 Jul 2013 10:33:06 GMT
Connection: close
What am I doing wrong?
I've used the GET method to check the command parameters and they're all optional.
From: http://docs.oracle.com/cd/E26576_01/doc.312/e24928/general-administration.htm
REST requests that add, update, or delete objects must specify the X-Requested-By header with the value "GlassFish REST HTML interface".
So EG:
curl -ik -X POST -H "Accept: application/json"
-H "Authorization: Basic YWRtaW46YWRtaW5hZG1pbg=="
-H "X-Requested-By: GlassFish REST HTML interface"
https://localhost:4848/management/domain/applications/application/MyApp/enable
Based on the answer above, ajusted for those who try to do it with the successor of Glassfish - the Payara Server:
Enable App
curl -ik -X POST \
-H 'accept: application/json;charset=UTF-8' \
-H 'authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'x-requested-by: GlassFish REST HTML interface' \
--data target=server \
--url https://localhost:4848/management/domain/applications/application/awesomeApp/enable
Disable App
curl -ik -X POST \
-H 'accept: application/json;charset=UTF-8' \
-H 'authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'x-requested-by: GlassFish REST HTML interface' \
--data target=server \
--url https://localhost:4848/management/domain/applications/application/awesomeApp/disable

How to play with the CloudApp API in CURL?

I am trying to play with the CloudApp API with CURL and it keeps giving me the redirect message, and I don't think I'm initializing it right. The docs are at http://support.getcloudapp.com/faqs/developers/api and my request currently looks like:
curl -G --digest -u user#domain.com:[censored] -H "Content-Type: application/json" http://my.cl.ly/items/new
Any ideas?
You may also need to include -H "Accept: application/json"