How to set the content-id in a Google Classroom API V1 request

不问归期 提交于 2019-12-14 03:13:11

问题


I'm creating a lot of batched requests and I want to keep track of which ones are successful and which ones error. I'm using all kinds of different requests with the Google Classroom API V1.

I want to set the content-ID to a unique value and reference it in the callbacks. Any help would be appreciated, especially in C#.

Here is a sample for adding a course deletion to a batch request:

requests[CurrentBatch].Queue<GoogleCourse>(serviceCredential.Service.Courses.Delete(course.Id), (content, error, i, message) =>
            {

                if (content != null)
                {
                    //add the classroom 
                    GoogleClassroom.DAL.Datamodule.SaveGoogleCourseIdByNameAndUser(content.Id, content.Name, content.OwnerId);
                    log.Write("Successfully Added\n");
                }
                if (error != null)
                {
                    log.Write("error:" + error.ToString() + "\n");
                }
                if (message != null)
                {
                    log.Write("message:" + message.Content.ReadAsStringAsync().Result.ToString() + "\n");
                }

            });

回答1:


Unfortunately the .NET client doesn't provide an easy way to set the Content-ID header for specific request in the batch. I've tried a few methods to manually set the Content-ID header but without success. The best alternative at the moment is to use the index of the request / response to link them together, and the index is passed into the callback handler as the 3rd parameter.



来源:https://stackoverflow.com/questions/32637718/how-to-set-the-content-id-in-a-google-classroom-api-v1-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!