Invalid Document Stream when uploading thumbnail to OneDrive - onedrive

I download a JPEG thumbnail.
curl -L 'https://api.onedrive.com/v1.0/drive/items/EF393A3B6CA330A3!112/thumbnails/0/small/content' \
-H "Authorization: Bearer $AUTH" \
> image
I then try to use that very same downloaded image as a custom thumbnail.
curl -v 'https://api.onedrive.com/v1.0/drive/items/EF393A3B6CA330A3!112/thumbnails/1/source/content' \
-X PUT -H 'Content-Type: image/jpeg' -H "Authorization: Bearer $AUTH" \
-d #image
but it doesn't work.
< HTTP/1.1 400 Bad Request
< Via: 1.1 BY3302____PAP061 (wls-colorado)
< Content-Length: 71
< Content-Type: application/json
* Server Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0 is not blacklisted
< Server: Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
< X-WLSPROXY: BY3302____PAP061
< X-MSNSERVER: DM2301____PAP093
< X-QosStats: {"ApiId":0,"ResultType":2,"SourcePropertyId":0,"TargetPropertyId":42}
< X-ThrowSite: 3683.1abb
< X-AsmVersion: UNKNOWN; 19.22.0.0
< P3P: CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"
< Date: Fri, 17 Jul 2015 06:59:24 GMT
<
* Connection #0 to host api.onedrive.com left intact
{"error":{"code":"invalidRequest","message":"Invalid Document Stream"}}
What does OneDrive want me to do to upload the thumbnail?
I looked at the "example", but it didn't shed much light.

Related

Apple Music Kit unable to get proper Music-User-Token generated

Im creating a login with apple music feature on a PHP coded website, so far so good. Im able to login get the access_token from the user, im also able to get public track and playlist info using my encrypted developer token.
But I would also like to create a library playlist for that logged in user, the docs in apple suggest that to make personal changes I need to add a special header:
Music-User-Token: [music user token]
I assumed that the Music-User-Token is the access_token of the user, but that fails, I also tried the id_token from the logged in session, but it also fails.
My end CURL request looks something like this:
curl -v \
-H 'Content-Type: application/json' \
-H 'Music-User-Token: USER_MUSIC_TOKEN' \
-H 'Authorization: Bearer DEVELOPER_TOKEN' \
--request POST \
--data '{"attributes":{"name":"1622799194 playlist","description":""},"relationships":{"tracks":{"data":[{"id":"1560879523","type":"songs"}]}}}' \
"https://api.music.apple.com/v1/me/library/playlists"
The response I get is:
* upload completely sent off: 135 out of 135 bytes
< HTTP/1.1 403 Forbidden
< Content-Type: application/json;charset=utf-8
< Content-Length: 132
< Server: daiquiri/3.0.0
< x-apple-jingle-correlation-key: 7QETXMYLA5HYFGWO75NMIYAZ2E
< x-apple-request-uuid: fc093bb3-0b07-4f82-9ace-ff5ac46019d1
< b3: fc093bb30b074f829aceff5ac46019d1-3adb16d23e03d043
< x-b3-traceid: fc093bb30b074f829aceff5ac46019d1
< x-b3-spanid: 3adb16d23e03d043
< apple-seq: 0.0
< apple-tk: false
< apple-originating-system: MZStorePlatform
< X-Apple-Application-Site: ST11
< X-Apple-Application-Instance: 2513606
< x-responding-instance: MZStorePlatform:2513606:::
< apple-timing-app: 11 ms
< Cache-Control: private, no-cache, no-store, no-transform, must-revalidate, max-age=0
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< is-jetty: true
< x-apple-lokamai-no-cache: true
< x-daiquiri-instance: daiquiri:48626004:st53p00it-qujn14050101:7987:21HOTFIX5
< Access-Control-Allow-Origin: *
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Date: Fri, 04 Jun 2021 09:55:15 GMT
< Connection: close
<
* Closing connection 0
{"errors":[{"id":"7QETXMYLA5HYFGWO75NMIYAZ2E","title":"Forbidden","detail":"Invalid authentication","status":"403","code":"40300"}]}
How do I generate the proper for Apple Music Kit Music-User-Token manually?
Thank you!

Kibana Rest API redirects to login

I'm new to ElasticSearch and Kibana. I'm trying to use Kibana's REST API, but the response i get are redirections to /login whatever the request i try.
The basePath has been modified in kibana.yml :
server.basePath: "/demo"
server.rewriteBasePath: true
Every request, such as :
$ curl -v -u user:passwd -X GET "127.0.0.1:5601/demo/api/features"
gets the following response :
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 5601 (#0)
* Server auth using Basic with user 'user'
> GET /demo/api/features HTTP/1.1
> Authorization: Basic xxxxxxxx
> User-Agent: curl/7.38.0
> Host: 127.0.0.1:5601
> Accept: */*
>
< HTTP/1.1 302 Found
< location: /demo/login?nextUrl=/demo/api/features
< kbn-name: kibana
< content-type: text/html; charset=utf-8
< cache-control: no-cache
< content-length: 0
< connection: close
< Date: Thu, 26 Nov 2020 10:32:56 GMT
<
* Closing connection 0
I'm using v7.2.0 with Linux.
Could someone tell me what i'm doing wrong ?
Best regards
The problem came from the use of the plugin readonlyrest.
First, I had to log in and retrieve the cookie, before querying for anything :
curl -v -X POST "127.0.0.1:5601/demo/login" -d "username=user&password=passwd"-H "kbn-xsrf: true" -H 'Accept: application/json' -c cookie.txt
And then use with the cookie :
curl -v -X GET "127.0.0.1:5601/demo/api/features" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -H "Accept: application/json" -b cookie.txt
In more recent versions of Kibana and ROR we can obtain the cookie with:
curl '127.0.0.1:5601/login' -H 'kbn-xsrf: true' -H 'Content-Type: application/json' --data-raw '{"username":"user","password":"password"}' -c cookie.txt

Authenticate via api-key in chrome web store api

I would like to automate chrome extension deployment and followed this guide for the most part: https://developer.chrome.com/webstore/using_webstore_api. I created a project in my developer console, activated the Chrome Web Store API. Next step is creating the right credentials. There are three different ones, when i let google help me choose it tells me that API-key is just fine to use for this API, so i did.
My question: How can i use this API-key to make API calls? I tried to include the key in the params as pointed out in the docs but that doesn't work. If this is the wrong approach i really don't understand, that these sort of authentication is suggested by the developer console.
As i try to automate things on a build server without using chrome or some other browser i cannot really use OAuth credentials.
curl \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-H "Expect:" \
-X GET \
-v \
"https://www.googleapis.com/chromewebstore/v1.1/items/ITEM_ID?projection=draft&key=API_KEY"
results in
https://www.googleapis.com/chromewebstore/v1.1/items/ITEM_ID\?projection\=draft\&key\=API_KEY
* Trying 172.217.17.234...
* Connected to www.googleapis.com (172.217.17.234) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.googleapis.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /chromewebstore/v1.1/items/ITEM_ID?projection=draft&key=API_KEY HTTP/1.1
> Host: www.googleapis.com
> User-Agent: curl/7.43.0
> Accept: */*
> x-goog-api-version: 2
> Content-Length: 0
>
< HTTP/1.1 401 Unauthorized
< Vary: X-Origin
< WWW-Authenticate: Bearer realm="https://accounts.google.com/"
< Content-Type: application/json; charset=UTF-8
< Date: Thu, 15 Sep 2016 14:14:18 GMT
< Expires: Thu, 15 Sep 2016 14:14:18 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
* Connection #0 to host www.googleapis.com left intact
{"error":{"errors":[{"domain":"global","reason":"required","message":"Login Required","locationType":"header","location":"Authorization"}],"code":401,"message":"Login Required"}}
I also tried to set it as header but neither of these worked.

cURL hangs at: "no chunk, no close, no size. Assume close to signal end"

When using this command to stream upload to a Apache/PHP server
curl -X POST \
-i --data-binary #customfile.app \
-H "Transfer-Encoding: chunked" \
-H "Content-Type: application/app" \
-H "X-CustomHeader1: customvalue1" \
-H "X-CustomHeader2: customvalue2" \
-H "X-CustomHeader3: customvalue3" \
-H "X-CustomHeader4: customvalue4" \
-H "X-CustomHeader5: customvalue5" \
-H "X-CustomHeader6: customvalue6" \
--ignore-content-length \
--progress-bar -vvv \
http://[DOMAIN]/upload.php
The command hangs as follows:
* Hostname was NOT found in DNS cache
* Trying [IP_ADDRESS]...
* Connected to [DOMAIN] ([IP_ADDRESS]) port 80 (#0)
> POST /upload.php HTTP/1.1
> User-Agent: curl/7.37.1
> Host: [DOMAIN]
> Accept: */*
> Transfer-Encoding: chunked
> Content-Type: application/app
> X-CustomHeader1: customvalue1
> X-CustomHeader2: customvalue2
> X-CustomHeader3: customvalue3
> X-CustomHeader4: customvalue4
> X-CustomHeader5: customvalue5
> X-CustomHeader6: customvalue6
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Date: Thu, 12 Feb 2015 11:10:17 GMT
Date: Thu, 12 Feb 2015 11:10:17 GMT
* Server Apache is not blacklisted
< Server: Apache
Server: Apache
< Vary: Content-Type
Vary: Content-Type
< Content-Length: 0
Content-Length: 0
< Connection: keep-alive
Connection: keep-alive
* no chunk, no close, no size. Assume close to signal end
<
Now, when the no chunk, no close, no size. Assume close to signal end message appears I do a checksum on both the local and server file to prove they are both the same, which they are. Meaning that the file successfully uploads, but for some reason the connection is not closed.
Why is that and how do I resolve it? Can I tell cURL to close the connection when the whole file has been uploaded? Thanks
You specifically tell curl to ignore the content-length set by the server. Because of this the end of the response will be assumed to be connection close. But the server does not close because it waits for more requests.
Apart from that: I don't think you can just add "Transfer-Encoding: chunked" as a custom header. It is not enough to tell the server that the content will be sent in chunks but curl actually has to use chunked encoding which it probably does not.
I had a funny case when this happened with a JSP page.
Flushing a newline helped:
<%
out.println("");
out.flush();
%>

How do I use the Unfuddle API to get files?

I'm new to web programming, as you are about to see.
I'm trying to periodically retrieve files from Unfuddle using their API. I tried their first code example and it seems to return valid information from my HTTP GET call, but I don't know how to use this information to get specific files onto my hard drive. How is this done?
Here is my exact HTTP GET call and response (except for the password being replaced):
bmihura#bmihura-PC ~
$ curl -i -u bmihra:password -X GET \
> -H 'Accept: application/xml' \
> 'http://spowertech.unfuddle.com/api/v1/projects/projects.xml'
HTTP/1.1 302 Found
Server: nginx/1.0.5
Date: Fri, 17 Aug 2012 11:53:23 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.8
Vary: Accept-Encoding
Cache-Control: no-cache
Set-Cookie: authenticated=; domain=.unfuddle.com; path=/; expires=Thu, 01-Jan-19 70 00:00:00 GMT
Set-Cookie: authenticated=false; path=/; expires=Fri, 17-Aug-2012 13:51:24 GMT
Set-Cookie: unfuddle_secure=; domain=.unfuddle.com; path=/; expires=Thu, 01-Jan- 1970 00:00:00 GMT
Set-Cookie: _unfuddle_session=; domain=.unfuddle.com; path=/; expires=Thu, 01-Ja n-1970 00:00:00 GMT
Set-Cookie: _unfuddle_session=BAh7BjoPc2Vzc2lvbl9pZCIlZGIzOTlmMTcxZGIwZjE4MDRhZW RkZGVmOGI4YjIxNzM%3D--0833ed386e5cd62894bb8dd787d856545897df35; path=/; expires= Fri, 17-Aug-2012 13:53:24 GMT; HttpOnly
Location: https://spowertech.unfuddle.com/projects/projects
Content-Length: 115
Status: 302
<html><body>You are being redirected.</body></html>
You need to use https instead of http in the url at the bottom - i.e.
curl -i -u bmihra:password -X GET \
-H 'Accept: application/xml' \
'https://spowertech.unfuddle.com/api/v1/projects/projects.xml'
In addition, to get it to work via my windows machine I had to replace the ' with " in the -H and remove the ' around the url. So I ended up using
curl -i -u bmihra:password -X GET \
-H "Accept: application/xml" \
https://spowertech.unfuddle.com/api/v1/projects/projects.xml
Hope that helps!