OneDrive / onedrive-sdk-csharp

OneDrive SDK for C#! https://dev.onedrive.com
Other
294 stars 143 forks source link

File upload optional parameters #110

Closed snazarian closed 8 years ago

snazarian commented 8 years ago

Hi there,

The IItemContentRequestBuilder interface does not support providing optional parameters in the request. It has only the following method: IItemContentRequest Request();

It is impossible to provide "@name.conflictBehavior" optional query string parameter in the request as described here: https://dev.onedrive.com/items/upload_put.htm.

Are you going to support this? Thanks.

ginach commented 8 years ago

You can add query strings when building the request. For example:

var request = client
    .Drive
    .Items["itemId"]
    .Content
    .Request(new List<Option> { new QueryOption("@name.conflictBehavior", "rename") });

I understand this should be more discoverable. I'll take the feedback to the team since we would need to find a way to incorporate it into our codegen process.

snazarian commented 8 years ago

Thank you for response, but the code you provided is not buildable, because the Request() method does not accept any parameters, you can write only this way:

var request = client
    .Drive
    .Items["itemId"]
    .Content
    .Request();

Which definitely does not give a possibility to provide query string parameter.

ginach commented 8 years ago

Bleh, this is a bug.

Here's your workaround:

var requestBuilder = var request = client
    .Drive
    .Items["itemId"]
    .Content as ItemContentRequestBuilder;

var request = new ItemContentRequest(
    requestBuilder.RequestUrl,
    requestBuilder.Client,
    new List<Option> { new QueryOption("@name.conflictBehavior", "rename") });
snazarian commented 8 years ago

Thank you for workaround, but I think this bug will be fixed in the nearest future, right?

ginach commented 8 years ago

Fixed in the latest package push.