Find and save JSON file from server response to a browser action - json

During activities in the browser (Mozilla Firefox) game-server sending response with the JSON in the body. Example:
What I'm looking for is a way to save/rewrite this JSON file body from this server into txt file on my pc automatically (each time server sending me a JSON file I want it to be saved in the folder on my pc eg. C:/DevProj/data.txt).
I definitely can save it manually using dev mode(f12), but I'm looking for something to automate this process.
How can I automate the save process?
Raw response JSON Headers example:
HTTP/1.1 200 OK
Date: Wed, 23 Nov 2022 13:55:59 GMT
Content-Type: text/json; charset=windows-1251
Content-Length: 7510
Connection: keep-alive
Pragma: no-cache
Expires: 0
Cache-Control: no-cache
HTTPVersion: 1.1
cache-control: no-cache
pragma: no-cache
server: Apache
Reason: OK
expires: 0
battleidproxy: 1669211553.97558
Access-Control-Allow-Origin: http://*.combats.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Content-Version
Access-Control-Expose-Headers: Content-Length,Content-Range
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://*.combats.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Content-Version
Access-Control-Expose-Headers: Content-Length,Content-Range
Access-Control-Allow-Credentials: true
Raw Response JSON body example:
{"timeout":0,"manahealleft":0,"damage":[{"sDamage":"00000","nDamage":"1164"},{"sDamage":"00000","bEnemy":1}],"healleft_euro":2535,"methods":[{"sMagicType":null,"bEnable":0,"sTarget":"self","sID":"hp_defence","bFreeCast":1,"bSelectTarget":0,"arrResources":"0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0","sSrc":"hp_defence","sDesc":"someText.","sText":"someText","sTargetLogin":null,"bAuto":0},{"sText":"someText","sDesc":"someText","arrResources":"0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0","bSelectTarget":0,"sSrc":"hp_enrage","bAuto":0,"sTargetLogin":null,"sMagicType":null,"sTarget":"self","bEnable":0,"bFreeCast":1,"sID":"hp_enrage"},{"bEnable":0,"sTarget":"self","sMagicType":null,"sID":"hit_luck","bFreeCast":1,"bSelectTarget":0,"arrResources":"5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0","sSrc":"hit_luck","sText":"someText","sDesc":"someText","sTargetLogin":null,"bAuto":0},{"sTargetLogin":null,"bAuto":0,"sText":"someText","sDesc":"someText","bSelectTarget":0,"sSrc":"block_aftershock","arrResources":"0,0,0,3,0,0,0,0,0,0,4,0,0,0,3,0","bFreeCast":1,"sID":"block_aftershock","sMagicType":null,"sTarget":"current_enemy","bEnable":0},{"sID":"block_activeshield","bFreeCast":1,"bEnable":0,"sTarget":"self","sMagicType":null,"bAuto":0,"sTargetLogin":null,"bSelectTarget":0,"arrResources":"0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0","sSrc":"block_activeshield","sDesc":"someText","sText":"someText"},{"sTargetLogin":null,"bAuto":0,"sDesc":"someText","sText":"someText","bSelectTarget":0,"sSrc":"novice_def","arrResources":"0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0","bFreeCast":1,"sID":"novice_def","sTarget":"self","bEnable":1,"sMagicType":null},{"sMagicType":null,"bEnable":0,"sTarget":"self","sID":"block_kupol","bFreeCast":1,"bSelectTarget":0,"arrResources":"1,0,0,2,0,0,0,0,0,0,7,0,0,0,0,0","sSrc":"block_kupol","sDesc":"someText","sTargetLogin":null,"bAuto":0},{"sTarget":"self","bEnable":0,"sMagicType":null,"bFreeCast":1,"sID":"hp_regen","sDesc":"someText","sText":"someText","arrResources":"0,0,0,0,0,5,0,0,0,0,3,0,0,0,0,0","bSelectTarget":0,"sSrc":"hp_regen","bAuto":0,"sTargetLogin":null},{"sMagicType":null,"sTarget":"self","bEnable":0,"bFreeCast":1,"sID":"block_fullshield","sDesc":"someText","sSrc":"block_fullshield","bSelectTarget":0,"arrResources":"0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0","sTargetLogin":null,"bAuto":0},{"sID":"hit_willpower","bFreeCast":1,"bEnable":1,"sTarget":"self","sMagicType":null,"bAuto":0,"sTargetLogin":null,"bSelectTarget":0,"arrResources":"3,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0","sSrc":"hit_willpower","sText":"someText","sDesc":"someText"},{"sTarget":null,"bEnable":0,"sMagicType":null,"bFreeCast":0,"sID":"break","sDesc":null,"sText":null,"bSelectTarget":0,"sSrc":"break","arrResources":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0","bAuto":0,"sTargetLogin":null},{"sTarget":"self","bEnable":0,"sMagicType":null,"bFreeCast":1,"sID":"preparation","sDesc":"someText","bSelectTarget":0,"arrResources":"0,0,0,0,0,0,0,0,0,0,100,53,0,0,0,0","sSrc":"preparation","sTargetLogin":null,"bAuto":0},{"sText":"someText","sDesc":null,"sSrc":"pet_unleash","bSelectTarget":0,"arrResources":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0","sTargetLogin":null,"bAuto":0,"sMagicType":null,"sTarget":null,"bEnable":0,"bFreeCast":1,"sID":"pet_unleash"}],"attacks":1,"noblocks_mod":"1","resources":{"parry":"1","block":"1","krit":"0","spirit":"10","counter":"0","spiritmax":"10.00","hit":"3","hp":"4"},"healleft":1690,"defend":1,"is_json":1,"buttons":{"change_enemy":0,"hide_log":0,"gameover":0,"exit":0,"leader_change":0,"commit":1,"refresh":0,"focus_target":0,"leader_kill":0,"refresh2":1},"defend_text":3,"timetoattack":30,"groups":2,"attacks_text":"1","id":"1669211553.97558","canuse":null,"manahealleft_euro":0,"lastlog":214,"message":"","logs":["211|<font class=date>16:55</font> <span class=\"b2\">Бродячий Пламенный Сантехник</span>, победив страх, решил поразить <span class=\"b1\">Ragnir</span> заклятьем "<strong><B><FONT color=#A00000>Огненный щит</FONT></B></strong>". <Font Color=#006699 title=\"<b>Бродячий Пламенный Сантехник</b><BR><BR>Мощь: ??, Защита: 148, Подавление: ??\"><b>-8</b></Font> [42/845]","212|<SCRIPT>adh(5,34,\"16:55\",12)</SCRIPT><span class=\"b2\">Бродячий Пламенный Сантехник</span> пошатнулся, и вдруг, <span class=\"b1\">Ragnir</span> робко рубанул тяжелой дубиной в правую ногу противника. <Font Color=#006699 title=\"Мощь: 0, Защита: ??\"><b>-12</b></Font> [150/500]","213|<SCRIPT>adh(3,234,\"16:55\",21)</SCRIPT><span class=\"b2\">Бродячий Пламенный Сантехник</span> закашлялся и <span class=\"b1\">Ragnir</span> остановил тычок узловатым корнем в левый бок.","214|<font class=sysdate>16:55</font> <span class=\"b1\">Ragnir</span> утратил здоровье от <B>Вони Зомби</B>. <Font Color=green title=\"<b>Теплый Зомби</b>\"><b>-12</b></Font> [30/845]<SCRIPT>dv();</SCRIPT>"],"user":[{"sName":"Ragnir","nLevel":"6","sAlign":0,"slots_cd":{"102":0,"100":0,"101":0,"103":0,"104":0},"nMaxHP":845,"sTitle":"<B>Ragnir</B><BR>Сила: 28<BR>Ловкость: 3<BR>Интуиция: 3<BR>Выносливость: 50<BR>Уровень духа: 10.00","nHP":30,"sClan":"","nCount":1,"sID":"1668473194","role":"256","config_blinker":0,"arrEffects":[{"sSrc":"http://img.combats.com/i/misc/icons/ico_pet_dog.gif","sTitle":"<B>Верный Друг [5]</B> (Эффект)<BR>Осталось: 23 ч. 56 мин. <BR><BR>Уровень жизни (HP): +125<BR><BR>Автор: <B>Рык (зверь Ragnir)</B><BR>","debuff":0,"ot":0,"sType":null,"sID":"ico_pet_dog"},{"sType":null,"sID":"hp_enrage","sTitle":"<B>Ярость</B> (Превозмогание)<BR><BR>Мф. мощности урона (%): +5<BR>Мф. мощности магии стихий (%): +5<BR>","sSrc":"http://img.combats.com/i/misc/icons/hp_enrage.gif","debuff":0,"ot":0},{"sType":null,"sID":"bot_rottenwater","sStack":"x3","debuff":0,"sTitle":"<B><U>Вонь Зомби</U></B> (Эффект) x 3<BR>Зарядов: 99982<BR>Вонь разложения, усиленная жаром, становится невыносимой<BR><BR>Автор: <B>Теплый Зомби</B><BR>","sSrc":"http://img.combats.com/i/misc/icons/bot_rottenwater.gif","ot":0}],"side":1,"group":1,"sVirtID":"A0WMzpCFGYzSw"},{"sName":"Бродячий Пламенный Сантехник","sAlign":0,"nMaxHP":500,"sTitle":"<B>Бродячий Пламенный Сантехник</B><BR>Сила: 0<BR>Ловкость: 10<BR>Интуиция: 15<BR>Выносливость: 30<BR>","nHP":150,"nLevel":"7","enemy":1,"role":0,"sClan":null,"sID":"612716","nCount":1,"side":2,"arrEffects":[],"sVirtID":"A0szjb.TQxYYc"}],"list":[[1,"Ragnir",30,720,0,0,0,0,0,0,0],[2,"Бродячий Пламенный Сантехник",150,"500",0,0,1,0,0,0,1]],"i_dead":null}
I've tried some Firefox extensions such as HeaderSpy and some other tools but can't find anything that would suits my needs.

Related

Authorization and Get request autotest

Can anyone tell me how to make Autorization and sending GET request to api using Python 3
1 step - Authorization
2 step - getting maps (using F12 in Google Chrome:)
General:
Request URL: https://xxxxxxxxxxru/api/v2/offices/270/couriers?limit=100&offset=0
Request Method: GET
Status Code: 200
Remote Address: xxx.yyy.zzz.aaa:abc
Referrer Policy: no-referrer-when-downgrade
Response headers:
cache-control: no-cache, no-store, max-age=0, must-revalidate
content-encoding: gzip
content-type: application/json;charset=UTF-8
date: Wed, 14 Aug 2019 09:15:51 GMT
expires: 0
pragma: no-cache
server: nginx
status: 200
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: DENY
x-powered-by: Express
x-xss-protection: 1; mode=block
Provisional headers are shown
Request headers:
Accept: application/json, text/plain, */*
PWT: xxxxxxxxyyyyyyyyyzzzzzz
etc
My code:
from requests.auth import HTTPDigestAuth
#import autorization
import requests
url_1="https://xxxxxxxxxxxxx.ru/api/v2/maps?dateEnd=2019-08-14&dateStart=2019-08-14&limit=100&officeCode=270&offset=0&onlyEmpty=false&typeBasis="
headers1 = {
'Accept': 'application/json,',
'Accept': 'text/plain',
'Accept': '*/*',
'PWT': 'xxxxxxyyyyyyyyyyyzzzzzzz',
'Referer': 'https://xxxxxxxxxxxxx.ru/',
'Sec-Fetch-Mode': 'cors',
'X-Auth-Token': 'xxxxxxyyyyyyyyyyyzzzzzzz',
'X-User-Lang': 'rus'}
response = requests.get(url_1, headers=headers1)
print(response)
It was easy, lol. Only what should do - add ".text" int the end of "print(response)", i.e. "print(response.text)"
and after running request i've got correct response

Image saved con Amazon S3 bucket not showing on HTML5 canvas. Crossorigin issue

I have an image saved on my AWS S3 bucket. This is my CORS configuration:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Also, the bucket has this policy:
{
"Version": "2012-10-17",
"Id": "Policy1468082822770",
"Statement": [
{
"Sid": "Stmt1468082812651",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::criptolibertad/*"
}
]
}
This is the image: https://criptolibertad.s3.amazonaws.com/Django/0_startproject.jpeg , as you can see, it is public. I use a library called Croppie that tries to load the image into a canvas. But the canvas doesn't show the image I don't know why. The js looks like this:
croppie_div.croppie('bind', {
url: "{{ carta_magicpy.imagen_base.url }}",
points: [10,10,300,600]
});
That url attribute is just a variable rendered by Django. It looks like this when it is rendered:
<img style="opacity: 0;" src="https://criptolibertad.s3.amazonaws.com/Django/0_startproject.jpeg" crossorigin="anonymous" class="cr-image">
Notice the crossorigin attribute. I went into Croppie's source and removed that attribute. But then I get the error:
Image from origin ... has been blocked from loading by Cross-Origin Resource Sharing policy:
No 'Access-Control-Allow-Origin' header is present on the requested
resource
How can I solve this?
Seems the CORS headers are still not set correctly. This related Croppie issue #119 mentions you can check that by looking at the response headers.
It's pretty easy to inspect the headers with curl, for the image stored in your bucket:
curl -I -H "Origin: https://stackoverflow.com/questions/38365182" -H "Access-Control-Request-Method: GET" https://criptolibertad.s3.amazonaws.com/Django/0_startproject.jpeg
HTTP/1.1 200 OK
x-amz-id-2: 9AaMwS9s2Im+OV6YlzVKrDW8RnbQqFt4Ygc+pRa3XM4iDmnJqlO8DQ7EjvpT4W4GnhGc0IvoQeI=
x-amz-request-id: CD4E7C50B5186192
Date: Fri, 15 Jul 2016 07:54:52 GMT
Last-Modified: Sat, 09 Jul 2016 05:13:33 GMT
ETag: "5733f7cd0187eb3a840bbe83e2c66a9b"
Accept-Ranges: bytes
Content-Type: image/jpeg
Content-Length: 33402
Server: AmazonS3
As opposed to the properly set up CORS headers on e.g imgur:
curl -I -H "Origin: https://stackoverflow.com/questions/38365182" -H "Access-Control-Request-Method: GET" http://i.imgur.com/HMf7XWD.jpg
HTTP/1.1 200 OK
Last-Modified: Wed, 06 Jul 2016 15:07:13 GMT
ETag: "7b01be4b9235542038f6d9793cc2c620"
Content-Type: image/jpeg
Fastly-Debug-Digest: f94b623450bb8143aff369600bf855d6332bb44c12070f02b0fc95648eac6ef3
cache-control: public, max-age=31536000
Content-Length: 2457350
Accept-Ranges: bytes
Date: Fri, 15 Jul 2016 07:55:15 GMT
Age: 277937
Connection: keep-alive
X-Served-By: cache-iad2131-IAD, cache-fra1232-FRA
X-Cache: HIT, HIT
X-Cache-Hits: 1, 1
X-Timer: S1468569315.725739,VS0,VE2
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Origin: *
Server: cat factory 1.0
As you can see the main difference is that imgur returns the headers Access-Control-Allow-Methods and Access-Control-Allow-Origin, while your S3 bucket does not.
I have followed the official Amazon documentation on the subject and applied the modified CORS configuration to my own bucket, the difference from your configuration is the AllowedHeader element, which defines the headers to allowed in response. I set my bucket to:
<AllowedHeader>*</AllowedHeader>
Here are the resulting headers on the image stored in my bucket:
curl -I -H "Origin: https://stackoverflow.com/questions/38365182" -H "Access-Control-Request-Method: GET" https://so38134984.s3.amazonaws.com/rainbow_dash.png
HTTP/1.1 200 OK
x-amz-id-2: ANxPKoL3JDsLDGerTf8gdcyRU7U4Ozg4eMYJ9ADlX/2qcBmx0dsmAbZxv2h/tFfQIXbkAs+x5iA=
x-amz-request-id: 737E30AE2F8634FC
Date: Fri, 15 Jul 2016 07:53:55 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Max-Age: 3000
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
Last-Modified: Mon, 04 Jul 2016 20:09:19 GMT
ETag: "3ad1bb64b913c2eadab216b96034b990"
Accept-Ranges: bytes
Content-Type: image/png
Content-Length: 148647
Server: AmazonS3
I assume my image will now work properly in your Croppie script.

HTTP 500 when trying to upload a file

Here is my Box upload POST to upload a file into a specific folder:
POST /api/2.0/files/content HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Accept: application/json
User-Agent: SOASoftware/7-HttpCore/4
Transfer-Encoding: chunked
Content-Type: multipart/form-data
Host: upload.box.com
Connection: Keep-Alive
attributes='{"name":"lead.txt", "parent":{"id":"2890481033"}}'&file=C:\SOA\Software\sm70\instances\nd\leads.txt
-----------------------------9051914041544843365972754266
<file-data>
-----------------------------9051914041544843365972754266
but I get this response, that doesn't help me to understand what the problem is:
HTTP/1.1 500
Age: 0
Date: Fri, 02 Jan 2015 09:06:09 GMT
Connection: close
EMPTY MESSAGE
Can anyone tell me what I'm doing wrong in my request to cause the HTTP 500, please?
It looks like your multipart request isn't properly formatted. The easiest way to do this is to use an SDK or find a library that can build a multipart request for you.
If you really want to build the request manually, then here's an example of what an upload request should look like:
POST https://upload.box.com/api/2.0/files/content HTTP/1.1
Host: upload.box.com
Authorization: Bearer ACCESS_TOKEN
Content-Length: 346
Content-Type: multipart/form-data; boundary=------------------------393329c2f2238ab4
--------------------------393329c2f2238ab4
Content-Disposition: form-data; name="attributes"
{"name":"my-file.txt", "parent":{"id":"0"}}
--------------------------393329c2f2238ab4
Content-Disposition: form-data; name="file"; filename="my-file.txt"
Content-Type: application/octet-stream
<file-data>
--------------------------393329c2f2238ab4--

SoapUI - Syntactical error in REST JSON

I am trying to run a login REST service in SoapUIPro with jason.
But I am getting the following syntactical error.
It's working fine when I switch to xml
Request
POST http://122.122.232.112/services/public/login HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/json
Accept: application/json
Content-Length: 115
Host: 122.122.232.112
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
{
"com.abc.dmb.cons.model.LoginInfo": {
"userId": "cons31312061521360",
"password": "Arif#1212"
}
}
Response
HTTP/1.1 400 Bad Request
Date: Fri, 06 Dec 2013 05:02:59 GMT
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Accept-Ranges: bytes
Server: abcd.setup.com.au
Content-Type: application/json;charset=ISO-8859-1
Transfer-Encoding: chunked
Connection: close
{"errorCode":"400","errorDescription":"The request sent by the client was syntactically incorrect."}
Please clarify
Cheers

Googleapi searching drive by title always returns 0 items

I'm using google api dot net client, and i'm a bit confused.
Following code returns me the entire list of a specific folder (with an Id: XXXXXXXXXXXXXXXXXXXXX).
List<File> result = new List<File>();
FilesResource.ListRequest request = service.Files.List();
request.Q = "'XXXXXXXXXXXXXXXXXXXXX' in parents";
request.MaxResults = 35;
FileList files = request.Fetch();
As example one item of this FileList is
"id": "0B5XhOfl0NZ2cZ1M1aVBPcVlTUTA",
"title": "87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC"
If i change the query, searching for a title, i receive always an empty FileList.
List<File> result = new List<File>();
FilesResource.ListRequest request = service.Files.List();
request.Q = "title = '87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC'";
request.MaxResults = 35;
FileList files = request.Fetch();
It does'nt matter, if the operator is '=' or 'contains', or by searching only a part of the directory name:
title contains '87BC1CAE'
I receive correct results only by searching for IDs.
Following code works flawless:
File file = service.Files.Get(fileId).Fetch();
Console.WriteLine("Title: " + file.Title);
Console.WriteLine("Description: " + file.Description);
Console.WriteLine("MIME type: " + file.MimeType);
Help please :)
#AliAfshar
Raw HTTP responses:
1st case (title = '87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC')
request.Fetch()
TestGoogleApi.vshost.exe Information: 0 : DotNetOpenAuth, Version=4.0.0.11165, Culture=neutral, PublicKeyToken=2780ccd10d57b246 (official)
TestGoogleApi.vshost.exe Information: 0 : Preparing to send AssertionFlowMessage (2.0) message.
TestGoogleApi.vshost.exe Information: 0 : Sending AssertionFlowMessage request.
TestGoogleApi.vshost.exe Information: 0 : HTTP POST https://accounts.google.com/o/oauth2/token
TestGoogleApi.vshost.exe Information: 0 : The following required parameters were missing from the DotNetOpenAuth.OAuth2.Messages.AccessTokenFailedResponse message: {error,}
TestGoogleApi.vshost.exe Information: 0 : Received UnauthorizedResponse response.
{Google.Apis.Drive.v2.Data.FileList}
_etag: "\"Q0cVodxX8sh4vfxZTlOyWcmmc0k/vyGp6PvFo4RvsFtPoIWeCReyIC8\""
_items: Count = 0
_kind: null
_nextLink: null
_nextPageToken: null
_selfLink: null
ETag: "\"Q0cVodxX8sh4vfxZTlOyWcmmc0k/vyGp6PvFo4RvsFtPoIWeCReyIC8\""
Items: Count = 0
Kind: null
NextLink: null
NextPageToken: null
SelfLink: null
2nd case ('XXXXXXXXXXXXXXXXXXXXXX' in parents )
request.Fetch()
TestGoogleApi.vshost.exe Information: 0 : DotNetOpenAuth, Version=4.0.0.11165, Culture=neutral, PublicKeyToken=2780ccd10d57b246 (official)
TestGoogleApi.vshost.exe Information: 0 : Preparing to send AssertionFlowMessage (2.0) message.
TestGoogleApi.vshost.exe Information: 0 : Sending AssertionFlowMessage request.
TestGoogleApi.vshost.exe Information: 0 : HTTP POST https://accounts.google.com/o/oauth2/token
TestGoogleApi.vshost.exe Information: 0 : The following required parameters were missing from the DotNetOpenAuth.OAuth2.Messages.AccessTokenFailedResponse message: {error,}
TestGoogleApi.vshost.exe Information: 0 : Received UnauthorizedResponse response.
{Google.Apis.Drive.v2.Data.FileList}
_etag: "\"Q0cVodxX8sh4vfxZTlOyWcmmc0k/Jyx7utsp71-_JwU5RHnI_VZmL5o\""
_items: Count = 1575
_kind: null
_nextLink: null
_nextPageToken: null
_selfLink: null
ETag: "\"Q0cVodxX8sh4vfxZTlOyWcmmc0k/Jyx7utsp71-_JwU5RHnI_VZmL5o\""
Items: Count = 1575
Kind: null
NextLink: null
NextPageToken: null
SelfLink: null
Updated on 2013 Feb 02
Ok excuse me for delay.
i used fiddler and here is captured result:
first request:
POST https://accounts.google.com/o/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=utf-8
User-Agent: DotNetOpenAuth/4.0.0.11165
Host: accounts.google.com
Cache-Control: no-store,no-cache
Pragma: no-cache
Content-Length: 603
Connection: Keep-Alive
grant_type=assertion&assertion_type=http%3A%2F%2Foauth.net%2Fgrant_type%2Fjwt%2F1.0%2Fbearer&assertion=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI0MjYwNjE5OTE1NzktYXEzMHBhcmVsYmpsb3BrMjlqcXFvdjhsdWhic2o3YjdAZGV2ZWxvcGVyLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJzY29wZSI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2F1dGgvZHJpdmUiLCJhdWQiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20vby9vYXV0aDIvdG9rZW4iLCJleHAiOjEzNjAwNjA0NDMsImlhdCI6MTM2MDA1Njg0M30.dk7Vdu-................-LIw0sFrVko-VWL7-elhz59VQcU_.........
first answer:
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Tue, 05 Feb 2013 09:34:03 GMT
Content-Type: application/json
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Content-Length: 128
{
"access_token" : "ya29.AHES6ZS-...........-a8HRHfMZ-NxXekx",
"token_type" : "Bearer",
"expires_in" : 3600
}
second request:
GET https://www.googleapis.com/drive/v2/files?alt=json&fields=items(id%2Ctitle)%2CnextPageToken&prettyPrint=true&maxResults=2000&q=title%20%3D%20'87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC' HTTP/1.1
Authorization: Bearer ya29.AHES6ZS-...........-a8HRHfMZ-NxXekx
Content-Type: application/json; charset=utf-8
User-Agent: TestGoogleApi google-api-dotnet-client/ Win32NT/6.1.7600.0 (gzip)
Host: www.googleapis.com
Accept-Encoding: gzip, deflate
second answer:
HTTP/1.1 200 OK
Expires: Tue, 05 Feb 2013 09:34:04 GMT
Date: Tue, 05 Feb 2013 09:34:04 GMT
Cache-Control: private, max-age=0, must-revalidate, no-transform
ETag: "Q0cVodxX8sh4vfxZTlOyWcmmc0k/vyGp6PvFo4RvsFtPoIWeCReyIC8"
Content-Type: application/json; charset=UTF-8
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 17
Server: GSE
{
"items": []
}
as you see items count is 0.
If i make the same request via web interface
https://developers.google.com/drive/v2/reference/files/list it gives me 2 items, as it should be.
This is made with https://developers.google.com/oauthplayground/
GET /drive/v2/files?alt=json&fields=items(id%2Ctitle)%2CnextPageToken&prettyPrint=true&maxResults=2000&q=title%20%3D%20'87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC' HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: OAuth ya29.AHES6ZSDr7bDFMQxjR........ObzyEhkzQmN
HTTP/1.1 200 OK
Content-length: 220
Via: HTTP/1.1 GWA
Content-location: https://www.googleapis.com/drive/v2/files?alt=json&fields=items(id%2Ctitle)%2CnextPageToken&prettyPrint=true&maxResults=2000&q=title%20%3D%20'87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC'
X-content-type-options: nosniff
Etag: "Q0cVodxX8sh4vfxZTlOyWcmmc0k/oUg90Ml6_g3EsaXCogiJOEMkZ-M"
X-google-cache-control: remote-fetch
-content-encoding: gzip
Server: GSE
Reason: OK
X-xss-protection: 1; mode=block
Cache-control: private, max-age=0, must-revalidate, no-transform
Date: Tue, 05 Feb 2013 15:30:09 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json; charset=UTF-8
Expires: Tue, 05 Feb 2013 15:30:09 GMT
{
"items": [
{
"id": "0B5XhOf....VlTUTA",
"title": "87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC"
},
{
"id": "0B5XhO....EbGRLVVVReGM",
"title": "87BC1CAE-A01C-43A1-BB21-BE3DA6D6C7DC"
}
]
}
Thank you very much, i really appreciate your help
Looks like the confusion is due to the fact that you are using a service account in your code, but comparing the results with what you see in the web interface.
When using the web interface or the OAuth Playground, you are authorizing the app to use your personal account and not a service account. The service account doesn't have access to the same files you have access to, as it is actually an application-owned account.
If you want to use a service account to access your files, you should perform domain-wide delegation as explained at https://developers.google.com/drive/delegation
This still doesn't explain why some queries return results and others don't, but please try everything again without using service accounts and update the issue if things still don't work as expected.