Hi, I am able to get data from my bucket using postman. But not with uploading to my bucket. I have followed both simple and multipart upload but none works, even when I try with OAuth 2.0 Playground. The error message does not make sense as I followed the documentation and supplied the Authentication.
Request Multipart:
POST /upload/storage/v1/b/[BucketName]/20230907/o?uploadType=multipart HTTP/1.1 Host: www.storage.googleapis.com Content-length: 522564 Content-type: multipart/related; boundary="===============2358174219149564973==" Authorization: Bearer [AccessToken]
--===============2358174219149564973==
Content-type: application/json
{"name":"file1.jpg"}
--===============2358174219149564973==
Content-type: image/png
[PNG FILE]
--===============2358174219149564973==--
Response Multipart:
HTTP/1.1 400 Bad Request Content-length: 224 Vary: Origin Server: UploadServer X-guploader-uploadid: ADPycduaV61OxD9WV22MQ6N_A8u81I_HTeGs-uxSCulwiKDPvUIVgMGVNF8fBHEZp6lPFjNrFID1AqvS_gAXglnstW5TqqegQImD Date: Thu, 07 Sep 2023 09:39:45 GMT Alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 Content-type: application/xml; charset=UTF-8
<?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidAuthentication</Code><Message>The provided authentication header is invalid.</Message><Details>Cannot use OAuth Authorization header with form POST.</Details></Error>
Request Simple:
POST /upload/storage/v1/b/[BucketName]/20230907/o?uploadType=media&name=file1.png HTTP/1.1 Host: www.storage.googleapis.com Content-length: 522366 Content-type: image/png Authorization: Bearer [AccessToken]
[IMAGE FILE]
Response Simple:
HTTP/1.1 401 Unauthorized Content-length: 131 Vary: Origin Server: UploadServer X-guploader-uploadid: ADPycdvHc8xUeyTm5NnvvQVn5aLTvYwh8ETQrA_DAQA2tKLlMaYoitV2L0q4m6Hm0PF-rRP8kCFivTAYXVFLVaFFZzn_L44PeYBF Date: Thu, 07 Sep 2023 09:50:50 GMT Alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 Content-type: application/xml; charset=UTF-8 Www-authenticate: Bearer realm="https://accounts.google.com/", error="invalid_token"
<?xml version='1.0' encoding='UTF-8'?><Error><Code>AuthenticationRequired</Code><Message>Authentication required.</Message></Error>
Solved! Go to Solution.
Nevermind, I am now able to insert new object. After comparing with download request, I found that I used https://storage.googleapis.com as base url for upload, rather than https://googleapis.com. The url stated in official documentation uses storage in front of googleapis, so I followed it without thinking it is the issue.
Nevermind, I am now able to insert new object. After comparing with download request, I found that I used https://storage.googleapis.com as base url for upload, rather than https://googleapis.com. The url stated in official documentation uses storage in front of googleapis, so I followed it without thinking it is the issue.