Last Updated:
September 29, 2021
by
Muskan Purohit
| Version: 3
| 67,310 views
| 1 follower
members are following updates on this item.
REST API endpoints can pass data within their requests through 4 types of parameters: Header, Path, Query String, or in the Request Body. Igloo APIs provide you the functionality to create, modify /update, and delete content and objects, so it is important to understand how certain endpoints pass data into their requests.
Header parameters: Parameters included in the request header, usually related to authorization.
After making the create session API calls against your digital workplace (visit creating a session with Igloo via APIs to learn more), a token is returned which is a necessary parameter to make subsequent API calls (visit the subsequent API calls page for more information). This parameter is passed in the header as it is an authorization credential. Example:
headers: { Accept: 'application/json', Cookie: `iglooauth=${this.token} }
Examples of this type of parameterizing can be found in a variety of Igloo APIs like:
/.api/api.svc/blogarticles/{blogArticleId}/update
As shown below, the blogArticleID is passing within the actual request URL.
/.api/api.svc/blogarticles/7217f760-c960-4233-a42c-2fc3ed41a9c1/update
?"
separator.In the query string, each parameter is listed one right after the other with an ampersand (&
) separating them. The order of the query string parameters does not matter. Example of updating a wiki article where the title, parentId, description, etc. are passed as query parameters. It is also beneficial to use URL Search Parameters to reduce the size of your query string for more complex queries. This works by storing the query string in a variable and then referencing it at the end of a request. Visit the MDN article on URLSearchParams for your reference.
updateWiki(wikiArticleId, title, parentId, description, content, urlTitle) { const querystring = `title=${title}&parentId=${parentId}&description=${description}&content=${content}&urlTitle=${urlTitle}`; axios.post(`https://${this.url}/.api/api.svc/wikiarticles/${wikiArticleId}/update?${querystring}`, null, this.options) .then((response) => { console.log(response.data.response); }) .catch((err) => { if (err) { console.log(err); } }); }
The JSON object contains key-value pairs and may include multiple levels of nesting. For example:
updateWiki(wikiArticleId) { var payload = new FormData(); payload.append("title", "This is the title."); payload.append("content", "This is the content"); var options = { headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded', } }; axios.post(`https://${this.url}/.api/api.svc/wikiarticles/${wikiArticleId}/update`, payload, options) .then((response) => { console.log(response.data.response); }) .catch((err) => { if (err) { console.log(err); } }); }
Be sure to refer to the API documentation as they contain the way the parameters need to be passed into the request. If you have questions about making API calls with our APIs or need guidance, you can contact the Developer Relations Team through devsupport@igloosoftware.com.