After update to API v3 Update won't work.
See original GitHub issueHello.
I use method to update file and it works fine. After I’ve updated library to API v3 and changed part of the code, it stopped working. I haven’t get any Exception
but file on Google Drive hadn’t changed. Similar method with _service.Files.Create
works fine.
public static File updateFile(DriveService _service, string _uploadFile, string _parent, string _fileId, string Description)
{
if (System.IO.File.Exists(_uploadFile))
{
File body = new File();
body.Name = System.IO.Path.GetFileName(_uploadFile);
body.Description = Description;
body.MimeType = GetMimeType(_uploadFile);
body.Parents = new List<string> { _parent };
byte[] byteArray = System.IO.File.ReadAllBytes(_uploadFile);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
try
{
FilesResource.UpdateMediaUpload request = _service.Files.Update(body, _fileId, stream, GetMimeType(_uploadFile));
request.Upload();
return request.ResponseBody;
}
catch (Exception)
{
return null;
throw;
}
}
else
{
return null;
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Github API v3: Update file not working (404)
After editing the file, I try to update the file. On my submit I post the following using jQuery: var postData = {...
Read more >API v3 REST - Add WorkLog is broken after update.
The script I am using is pretty similar to yours but I am noticing that $SdpUri + "/api/v3/worklog" is not working when viewing...
Read more >Re: API version update
It looks like you received this communication because a V3 API key was previously generated within your account, but based on the code...
Read more >Update project rest API is not working
The update project rest api doesn't seem to be working. First, the documentation says "all parameters are optional in the body of the...
Read more >v3 Deals update returns no properties found to update
v3 Deals update returns no properties found to update. I am working on integration with Hubspot using v3 API. I am trying to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This appears to be working as intended. As per the documentation,
request.Upload()
returns anIUploadProgress
which has enException
field which contains the exception, instead of throwing it. In this case an exception is being thrown, because in Drive v3Update()
requests use patch semantics and can only contain writeable fields in theFile
body. In your case you are first (unnecessarily) fetching the existingFile
object, which contains read-only fields.@erickoledadevrel thanks a lot!!!