Google Photos REST API “BASE_URL=dv” return "302 Moved" error - base-url

I was using Google Photos REST API to download my videos. Based on the documentations, I was using the below curl command with BASE_URL=dv parameters to get the video file and getting 302 Moved error but video is in READY state. Pasted the output below.
Kindly help to resolve the error.
API:
curl --compressed --output - --request GET --header 'Authorization: Bearer ACCESS_TOKEN' --header 'Accept: application/json' 'BASE_URL=dv'
Output:
<HTML>
<HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
here.
</BODY></HTML>

I believe your goal as follows.
You want to download the video as a file using curl command.
In this case, please use the following curl command.
Modified curl command:
curl -L "base-url=dv" -o sampleFilename
In this case, it seems that the access token is not required to be used.
Please use -L and --location for the redirect.
When base-url is https://lh3.googleusercontent.com/lr/###, please use https://lh3.googleusercontent.com/lr/###=dv as the URL as follows.
curl -L "https://lh3.googleusercontent.com/lr/###=dv" -o sampleFilename
References:
Video base URLs
curl.1 the man page

Related

How to import json report through automation using REST API and XRay for JIRA and Cucumber + Xray

I can manually import execution result(report.json) through jira and its giving proper status.But i want to achieve through automation i am unable to do so
How to do so
i tried using below curl command in terminal ..was unable to get expected result
curl -H "Content-Type: application/json" -X POST -u username:password --data #report.json http://myurl.net/rest/raven/1.0/import/execution/cucumber
Note that the curl request you showed is tailored for Xray on Jira server and from the screenshot you're showing, it seems that you're using Xray on Jira Cloud. That requires that you have a token that you need to obtain first of all using another request.
If you're doing it by "hand" (i.e. from the command line), you would need to so something like:
token=$(curl -H "Content-Type: application/json" -X POST --data #"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
My cloud_auth.json is something like:
{ "client_id": "215FFD69....","client_secret": "1c00f8f2c..." }
Please check in more detail the authentication API and the endpoint for importing cucumber results (there are two actually) in the cloud.

Works in curl (and Rested API Client) but not in Postman?

I am able to login my local (and remote server) with the following curl (which I generated using Postman)... and I can login successfully using another API Client (Rested) with the same params/headers/body that I am trying to use in Postman. I've turned off "SSL cert verification" and "Send Postman Token header" in settings (per other Stack Overflow answers).. but still getting an unauthorized response from server when using Postman (but not when using curl or Rested)
curl:
curl -X POST \ http://localhost:8080/api/user/login \ -H 'Accept:
application/json' \ -H 'Content-Type: application/json' \ -d '{
"email": "email#example.com",
"password": "examplemail**" }'
And here is my log..
I just solved my own Q.. and posting this answer because I've seen other questions re: curl working but postman not on SO and Postman communities. My solution was to check the Content-Length header and Connection headers. They were auto populating anyway, so after 'accepting' them as headers, the Postman request worked. Here is a screenshot of the headers that worked.

Using curl to render and return a pdf-file from jsreport

I'm trying to understand how to use [jsreport][1] in node.js.
Is it possible to get and save the pdf-file using curl?
I couldn't find any documentation in my jsreport installation and on the website. This is very unusual for a RESTful library, I'd expected a couple curl examples.
OK, this seems to work:
curl -H "Content-Type: application/json" -k -X POST https://127.0.0.1/api/report -d"{\"template\": { \"shortid\" : \"NkerYDOXusdf\" }}" > report.pdf

Is this a GET or POST request in cURL?

curl https://api.creditcard.com/charge \
-H "x-apikey: API_KEY " \
-d email=user#host.com \
-d amount=9.99 \
It seems like a GET to me, but why would an API have a GET for charging a card? Shouldn't it be POST?
When -d as in post data is passed to curl, it will do a post request. So your request will perform a post request. If you want to see more about what request curl is doing, just add -v for more verbose output from the request (including what http method is used).
If you want to force a type of request, just add -XMETHOD where METHOD can be any of the HTTP verbs (GET/POST/...).

curl -h or curl --header not working

i'm trying to connect ti a web api service, box-api, and following the tutorial i have to type this command to fetch a folder in the user content:
curl https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0 -H "Authorization: Bearer ACCESS_TOKEN"
I tryied to connect from the command line to test the command but it keep complaining about the -H or the --header command saying that it doesn exist:
-bash: -H: command not found
-bash: --header: command not found
but when i type curl --help the command is in the manual:
-H, --header LINE Custom header to pass to server (H)
I'm confused, what should i do to connect to this site and get the JSON content? Thanks
Your url has & sign. and this is making end of command on there(and running at background). You can remove this error by using quotes around. Like this
curl "https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0" -H "Authorization: Bearer ACCESS_TOKEN"
Hope this helps.
There seem to be two problems:
The '&' in the middle of the URL passed to curl,
The order of the statements. The curl manual reports a different order for the statements. Example:
curl -H "Authorization: Bearer AUTH_KEY" "https://api.box.com/2.0/folders/0/items?limit=2&offset=0"
This should be the complete solution.