#SharePoint Online #Notes from the #Field
To get all choices with REST API:
- Site Column:
- http://SITE/_api/web/fields/getByInternalNameOrTitle(fieldInternalName)
- List Column:
- http://SITE/_api/web/lists(LISTGUID)/fields/getByInternalNameOrTitle(fieldInternalName)
- https://SITE/sites/SITENAME/_api/web/lists/GetByTitle(LIBRARYNAME)/fields/getByInternalNameOrTitle(Category)
TypeScript Code Example
import * as React from 'react';
import axios from 'axios';
export const getChoiceField = (siteURL:string, list:string, field:string):Promise<any> => {
const restQuery:string = `${siteURL}/_api/web/lists/GetByTitle('${list}')/fields/getByInternalNameOrTitle('${field}')`;
return axios({method: 'get', url: restQuery, responseType: 'json'})
.then(response =>{
return response.data.value;
});
}
export default getChoiceField;