abujehad139 / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

Requests include parameters with default values instead of omitting those parameters #249

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

  YoutubeService youtube = new YoutubeService();
  youtube.Key = "API_KEY";
  SearchResource.ListRequest listRequest = youtube.Search.List();
  listRequest.Q = "searchTerm";
  SearchListResponse searchResponse = listRequest.Fetch();

What is the expected output? What do you see instead?

A HTTP request with only the "q" parameter set.
Even those Q is the only parameter that was specified, the actual HTTP request 
looks like

  https://www.googleapis.com/youtube/v3alpha/search?alt=json&key=API_KEY&prettyPrint=true&q=searchTerm&startIndex=0&order=SEARCH_SORT_RELEVANCE&maxResults=25

The client library includes URL query parameters that aren't explicitly asked 
for by the developer if the parameters are defined to have a default value in 
the API's discovery doc. None of the other languages' client libraries seem to 
do that, and it's arguably better to leave out the parameters that are not 
requested by the developer and rely on the server-side defaults.

Original issue reported on code.google.com by je...@google.com on 31 Aug 2012 at 3:17

GoogleCodeExporter commented 9 years ago
+1
It may lead to errors because a parameter is set in the URL and is also set 
(with a different value) in the HTTP Body.

For instance:
var service = new CoordinateService (auth); 

//Docs https://developers.google.com/coordinate/v1/jobs#resource 
Job jobBody = new Job (); 
jobBody.Kind = "Coordinate#job"; 
jobBody.State = new JobState (); 
jobBody.State.Kind = "coordinate#jobState"; 

CustomField p6ActivityID = new CustomField (); 
p6ActivityID.CustomFieldId = "7002"; 
p6ActivityID.Value = "2"; 
p6ActivityID.Kind = "customField";
jobBody.State.CustomFields = new CustomFields (); 
jobBody.State.CustomFields.CustomField = new List<CustomField>();
jobBody.State.CustomFields.CustomField.Add(p6ActivityID);

//Create the Job 
JobsResource.InsertRequest ins = service.Jobs.Insert (jobBody, TEAM_ID, "My 
Home", "51", "0", "Assign this Job with the .Net Client Library");
Job results = ins.Fetch (); 

--> will cause an error because the customField parameter is sent in the URL 
with an empty string as a value. While it is also sent in the HTTP Body with a 
specific value.

Original comment by nicol...@google.com on 5 Jan 2013 at 6:10

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 24 Jan 2013 at 2:53

GoogleCodeExporter commented 9 years ago
see https://codereview.appspot.com/7012049 for more details

Original comment by pele...@google.com on 1 Feb 2013 at 3:20