koltyakov / gosip

⚡️ SharePoint SDK for Go
https://go.spflow.com
MIT License
140 stars 32 forks source link

Unable to get list item field values. #30

Closed anurag2994 closed 4 years ago

anurag2994 commented 4 years ago

The structure for the List Item doesnot contain a field property. Tried getting field values using normalized method but I'm getting the following response.

"FieldValuesAsHtml": { "deferred": { "uri": "https://siteurl/_api/Web/Lists(guid'9e636015-184f-40a4-8d61-d005372dfe21')/Items(1)/FieldValuesAsHtml" } }, "FieldValuesAsText": { "__deferred": { "uri": "https://siteurl/_api/Web/Lists(guid'9e636015-184f-40a4-8d61-d005372dfe21')/Items(1)/FieldValuesAsText" } }, "FieldValuesForEdit": { "deferred": { "uri": "https://siteurl/_api/Web/Lists(guid'9e636015-184f-40a4-8d61-d005372dfe21')/Items(1)/FieldValuesForEdit" } }

Is there a method which will retrun me fields for a list item? What is the use of api.ListItemAllFieldsResp?

koltyakov commented 4 years ago

Could you please provide a code sample you use facing this? And what is the version of SharePoint?

A request can contain .Select("Field1,Field2,LookupField/Title") and .Expand("LookupField") based on which the shape of the returned data is managed. It could be that you provide a select with a limited set of fields so others were trimmed (expected).

Please check the article for unmarshalling https://go.spflow.com/samples/unmarshaling-responses if you have not yet.

It also makes sense to check the raw response (https://go.spflow.com/samples/basic-crud#getting-a-specific-item).

anurag2994 commented 4 years ago

Thanks for the prompt reply. Got it working.

I tried this query: sp.Web().Lists().GetByID(list.Data().ID).Items().GetByID(listItemID).Expand("FieldValuesAsText").Get() Now I'am able to get the results.

The previous call was this: sp.Web().Lists().GetByID(list.Data().ID).Items().GetByID(listItemID).Get() which did not return the fields.

Do I have to make 3 calls as the expand supports only one parameter? I have to fetch 3 values: FieldValuesAsHtml, FieldValuesAsText, FieldValuesForEdit

koltyakov commented 4 years ago

Great! Thanks for using the package.