Skip to content

Can't navigate after function w/ args #463

@kitsu

Description

@kitsu

First, I am trying to use this library to access an on-prem SharePoint farm. If anyone could foul up the implementation of a Microsoft defined spec I would expect it to be Microsoft.

Specifically I am trying to access items in a list. Lists are collections, and their items are sub-collections.
Lists are typically accessed via a function GetByTitle('title'), which is important in my case because the random Guid assigned to each list is different in each of our environments (dev, prod, etc).

The url I'm trying to achieve is:
https://devapps.org.org/application/_api/lists/GetByTitle('Companies')/items

It took me a while to figure out what the client wanted of me, but I eventually arrived at:

// Where _client is a correctly initialized ODataClient (using combined package V4.29)
var companies = await _client
    .For("SP.List")
    .Function("GetByTitle")
    .Set(new { title = "Companies" })
    .NavigateTo<SPCompany>("items")
    .FindEntriesAsync();

The url this produces is so painfully close to what I need, except the function call is encoded as query parameters:
https://devapps.org.org/application/_api/lists/GetByTitle?title='Companies'/items

Which is of course nonsense, and SharePoint returns BadRequest.

During my hours of fighting to make this work I see that at some point Simple.OData.Client did produce the desired format. I also saw an issue where someone asked for query-style function calls. Looking through the code I found the the V3 client FunctionFormat is hard-coded to FunctionFormat.Query, while the V4 uses FunctionFormat.Key (used here, and here).

Reading the V3 spec section 10.4.2.3.3 it states that the query-encoded form is only allowed for the final function in a Url (Probably since otherwise it isn't a valid Url).

If you have any guidance it would be appreciated.

BTW: The V3 package never worked for me. It complained about not being able to load the adapter, then after manually updating its dependencies it wouldn't build except to throw manifest errors.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions