?followLocation reduces the number of requests required for performing POST operations. ?followLocation is a query parameter that is specified at the end of the HTTP request and instructs Cortex to automatically follow the location header in the returned response for POST operations. For example, creating a search requires the client app to GET the search form, POST the search form, and then GET the location header in the response in order to retrieve the search results, see Search for Items. By using ?followlocation when POSTing the search form, Cortex API returns the search results instead of returning a link to the search results. See ?followLocation for Searches below for an example.
Use ?followLocation when:
- Adding an item to a cart
- Posting an order to a purchase
- Creating a profile
- Creating a billing address
- Selecting a billing address
- Selecting a payment method
?followLocation and ?zoom can be used together to reduce the number of HTTP requests. For more information, see Zoom
?followLocation for Searches
The URI below shows an example of searching for items using ?followLocation. In this URI example, ?followLocation returns the newly created search, instead of returning a response with a location header that links to the new search.
URI: POST https://www.onlinestore.com/searches/<scope>/keywords/items?followLocation
?followLocation for adding an item to a cart
The URI below shows an example of adding an item to a cart using ?followLocation. In this URI example, ?followLocation returns the newly created lineitem containing the item the customer added to their cart, instead of returning a response with a location header liking to the new lineitem.
URI: POST http://www.onlinestore/carts/default/lineitems/items/<scope>/<itemid>?followLocation