I can upload small drafts OK using the metadata endpoint (https://www.googleapis.com/gmail/v1/users/me/drafts), e.g.:
{"message":{"raw":"TUlNRS1WZXJzaW9uOiAxLjANClgtTWFpbGVyOiBNYWlsQmVlLk5FVCA3LjAuNC4zMjgNClRvOiBjaHJpcy53b29kQG5vdGFibHlnb29kLmNvbQ0KU3ViamVjdDogdGVzdCENCkNvbnRlbnQtVHlwZTogbXVsdGlwYXJ0L21peGVkOw0KCWJvdW5kYXJ5PSItLS0tPV9OZXh0UGFydF8wMDBfQUFEQV9FOUMzOEZCNy5BMjRFQjI2OSINCg0KDQotLS0tLS09X05leHRQYXJ0XzAwMF9BQURBX0U5QzM4RkI3LkEyNEVCMjY5DQpDb250ZW50LVR5cGU6IHRleHQvcGxhaW4NCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFibGUNCg0KVGVzdCBjb250ZW50DQotLS0tLS09X05leHRQYXJ0XzAwMF9BQURBX0U5QzM4RkI3LkEyNEVCMjY5DQpDb250ZW50LVR5cGU6IGFwcGxpY2F0aW9uL29jdGV0LXN0cmVhbTsNCgluYW1lPSJUcmFjZS5sb2ciDQpDb250ZW50LURpc3Bvc2l0aW9uOiBhdHRhY2htZW50Ow0KCWZpbGVuYW1lPSJUcmFjZS5sb2ciDQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBiYXNlNjQNCg0KVTNWdUlESTVJRXBoYmlBeU1ERXlJREV5T2pJek9qTTBMalkzTmlBNklDTXhNREExTXpvZ1YxTkJSVU5QVGs1QlFrOVNWRVZFT2lCVA0KYjJaMGQyRnlaU0JqWVhWelpXUWdZMjl1Ym1WamRHbHZiaUJoWW05eWRDNGdJRWc2TURVMU9USWdSam9uU0VOVFRsUlRiMk5yWlhSZg0KVTJWdVpDY2dRVG9uYzJWdVpDY2dWRG9uVTI5amEyVjBQVFUwTUM0Z1JtbHVhWE5vWldRZ2NtVjBjbmxwYm1jdUp5QU5DbE4xYmlBeQ0KT1NCS1lXNGdNakF4TWlBeE1qb3lNem96TkM0Mk9UQWdPaUFqTVRBd09Eb2dSWEp5YjNJNklDQklPakExTlRreUlFWTZKMU5sYm1SVg0KYzJWeVJHVm1hVzVsWkVoVVZGQk5aWE56WVdkbFFtOWtlU2NnVkRvblJYSnliM0lnYzJWdVpHbHVaeUIxYzJWeUlHUmxabWx1WldRZw0KWm1sc1pTQmpiMjUwWlc1MGN5QjBieUJqYkdsbGJuUWdLRUp2WkhrcExpQlNaWFIxY200OUxURXVKeUFOQ2xOMWJpQXlPU0JLWVc0Zw0KTWpBeE1pQXhNam95TXpvek5DNDJPVElnT2lBak1UQXdOVE02SUZkVFFVVkRUMDVPUVVKUFVsUkZSRG9nVTI5bWRIZGhjbVVnWTJGMQ0KYzJWa0lHTnZibTVsWTNScGIyNGdZV0p2Y25RdUlDQklPakExTlRreUlFWTZKMGhEVTA1VVUyOWphMlYwWDFObGJtUW5JRUU2SjNObA0KYm1RbklGUTZKMU52WTJ0bGREMDFOREF1SUVacGJtbHphR1ZrSUhKbGRISjVhVzVuTGljZ0RRcFRkVzRnTWprZ1NtRnVJREl3TVRJZw0KTVRJNk1qTTZNelF1TmprMElEb2dJekV3TURnNklFVnljbTl5T2lBZ1JYSnliM0lnY21WeGRXVnpkR2x1WnlCQ1lYTnBZeUJCZFhSbw0KWlc1MGFXTmhkR2x2Ymk0TkNsTjFiaUF5T1NCS1lXNGdNakF4TWlBeE1qb3lOVG96TVM0NE1EWWdPaUFqTVRBeE5Ub2dVMmgxZEdSdg0KZDI0NklDQkdjbVZsSUZCeWIzaDVJRk5sY25acFkyVWdjM1J2Y0hCbFpDNE5DZz09DQotLS0tLS09X05leHRQYXJ0XzAwMF9BQURBX0U5QzM4RkI3LkEyNEVCMjY5LS0NCg"}}
However, when I try a larger file that's still within the 35MB limit (e.g. an 11MB file), I get the following HTTP WebException:
The remote server returned an error: (413) Request Entity Too Large.
Is this a bug in the new API, or is this down to the fact I should be using the media endpoint instead for this kind of thing? If so, can anybody provide an example of how to do this using the .NET Client?
You need to use the /upload "media upload" path to upload anything over a few MB. The URL and POST format are slightly different:
You'd do:
POST https://www.googleapis.com/upload/gmail/v1/users/userId/drafts
add a HTTP header like "Content-type: multipart/related; boundary=\"part_boundary\""
POST body looks more like:
--part_boundary
Content-Type: application/json; charset=UTF-8
{
}
--part_boundary
Content-Type: message/rfc822
From: script#example.org
To: user#example.com
Subject: test
body here
--part_boundary--
See this for more info (which then links to this).
Related
I've setup two business developer applications (test & prod environments) to handle Facebook Login and posting an image to a group directly via a web app. The endpoint I'm using is the following:
https://graph.facebook.com/v14.0/{group-id}/photos?access_token={access_token}
I followed this documentation: https://developers.facebook.com/.../refer.../page/photos/...
with a POST request and Content-Type: multipart/form-data.
The request payload looks like the following:
-----------------------------41883366036964688284103242839
Content-Disposition: form-data; name="source"; filename="blob"
Content-Type: image/png
�PNG
{a bunch of alphanumeric chars........}
-----------------------------41883366036964688284103242839
Content-Disposition: form-data; name="caption"
{the caption of the image}
-----------------------------41883366036964688284103242839--
The test environment works flawlessly: I build the picture in javascript and then call the api endpoint against a test facebook group.
On the production environment, the VERY SAME call with the very same image returns the error:
"Please reduce the amount of data you're asking for, then retry your request"
The post actually makes his way on the Facebook group but without the image.
I tried putting the limit=1 param with no luck.
I tried "cross-posting" with the Facebook PROD app to the Facebook TEST group and it works, so it seems the problem is posting to the PROD Facebook group.
In the image below what I see in the browser when the request fails, it seems the image size is below the 4Mb limit given by Facebook. Is there a better way to check the size of the image I'm trying to send?
However, if the image is the same, how come in one group I get to post correctly and in the other I don't?
How can I overcome this?
When i was doing upload file to onedrive with following:
HTTP POST https://apiis.live.net/v5.0/{foldid}/files?access_token={ACCESS_TOKEN}
Content-Type: multipart/form-data; boundary={boundary}
--{boundary}
Content-Disposition: form-data; name="file"; filename="{filename}"
Content-Type: application/octet-stream
{File content goes here}
--{boundary}
by which I follow the guide from https://msdn.microsoft.com/en-us/library/office/dn659726.aspx
It always give me error "java.lang.Exception: HTTP 400. Bad Request".
Would one drive team or anyone help to give me advice what it was going wrong?
Thanks and Best Regards,
Ronald
It seems your request is malformed. I don't know how one drive works but after a quick overview on your link, did you try to remove the 'HTTP' before 'POST' header ?
Or is your file content properly sended ?
From the url, https://apis.live.net/v5.0/{folderid}/files?access_token={ACCESS_TOKEN}, this would indicate you are using the deprecated LiveConnect API. I would recommend using the supported APIs located at https://api.onedrive.com with the upload method described here https://dev.onedrive.com/items/upload_put.htm where the request does not need the multipart mime schema
PUT .../drive/root:/{parent-path}/{filename}:/content
Content-Type: text/plain
The contents of the file goes here.
Get more information about these APIs at https://dev.onedrive.com If the updated uploading method is still causing you trouble, please make sure to include the full HTTP response headers and body.
I'm using go in order to interact with cloud storage .
I can't use gsutil from the app engine and delete with the rm command ?
I can delete one object with DeleteObject or iterate over a range of objects and delete each one , but i`m looking for another solution something like DeleteMulti in Datastor.
Do you have a better solution for multi deletion ?
Each object that is deleted requires one call to GCS. Iterating over each object and calling delete is the easiest and likely best solution. If you need faster performance, you may want to send multiple delete requests to GCS at a time using multiple threads.
If this is a significant performance issue for your app, there is, however, another way, which I hesitate to mention because it adds significant complexity and doesn't buy much extra performance. GCS supports batching calls together into a single connection. It likely won't be much faster than sending delete requests over several threads, but it does behave more like a DeleteMulti call.
Effectively, batch calls work by sending a multipart HTTP request to the /batch path, each part of which representing an HTTP call. A request to delete several objects would look like this:
POST /batch HTTP/1.1
Host: www.googleapis.com
Content-Length: content_length
Content-Type: multipart/mixed; boundary="===============7330845974216740156=="
Authorization: Bearer oauth2_token
--===============7330845974216740156==
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: <b29c5de2-0db4-490b-b421-6a51b598bd22+1>
DELETE /storage/v1/b/example-bucket/o/obj1 HTTP/1.1
accept: application/json
--===============7330845974216740156==
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: <b29c5de2-0db4-490b-b421-6a51b598bd22+2>
DELETE /storage/v1/b/example-bucket/o/obj2 HTTP/1.1
accept: application/json
--===============7330845974216740156==--
There's more documentation on it here: https://cloud.google.com/storage/docs/json_api/v1/how-tos/batch
But, again, I recommend just sending individual delete requests. Batch calls are not atomic, which means some deletes might succeed while others fail. In the event one of the batch delete operations fails, you'll need to parse the batch response message to figure out which call failed so that you can retry it, which is very likely not worth the effort for the gain you'll get back.
basically my problems is use set-cookie header with angular (looks like he is ignored even with the withCredentials set to true) but here is the problem if i make the same request the cookies go, but if i change the path does't work.
Example;
POST http://localhost/app/api/oauth/ HTTP/1.1
[other headers and payload]
then i get the answer:
HTTP/1.1 200 OK
Set-Cookie: ; expires=Wed, 31-Mar-2015 01:34:53 GMT
and send a request to access a resource:
GET http://localhost/app/api/oauth/test HTTP/1.1
Cookie:blah=something;
until now evething is ok, but when i try to access other resources on my server:
GET http://localhost/app/api/othercontroller/test HTTP/1.1
the cookie is not send anymore, only if i access some path after the path that create the cookie.
that is what network monitor show me. But i can't see that blah coockie on the resource tab (on cookie area).
Note: i already try use secure cookie or not and use http only cookie or not and all combinations between both of then. And i try don't use CORS or enable CORS, but anyone work too.
Anyone know what can be ?
Thanks for you time and patience.
I'm pasting my suggestion from my comment.
Your initial cookie is set in a response of a HTTP endpoint path that is deeper than your second request.
Set-Cookie: ; Domain=foo.com; Path=/; expires=Wed, 31-Mar-2015 01:34:53 GMT
You may specify where to put your cookie by specifying a Path parameter in your response header like given above.
Using SignalR Silverlight client, the request to server is not JSON. Actually, it is JSON but it is UrlEncoded as value of field "data", something like this (POST payload):
data=%7b%22I%22%3a%220%22%2c%22H%22%3a%22s3Hub%22%2c%22M%22%3a%22notify%22%2c%22A%22%3a...
with header
Content-Type: application/x-www-form-urlencoded
This is not what I can easily visually check in tools like Fiddler. The response is OK - JSON as I'd expected. How could I configure the client to use application/json as Content-Type?
You can't. Today we send a form urlencoded payload to the server. In a future version we might send via JSON. It's an implementation detail that really shouldn't affect your application.