Coveo Search API call
With the new package upgrade of coveo, we have an AttachedResult object being inserted on attach of results. We are adding more fields to the same object in a trigger. To do this, we need other information of the result object. So we need to do an API call to coveo and get that specific result. Ex : https://cs12.salesforce.com/08730000000l3I9AAI This is the Result Url in the Attached Result object. 08730000000l3I9AAI is the ID I have to query for the result from Coveo. Is it really possible to do rest API call from trigger with the ID we have? If so, What all parameters I need to do a rest API call to get one result per Id. CoveoSolutions.CoveoGlobal.generateSearchToken(); This gives the search token. (Please confirm if this is right) What End point URL I need to set. Could you please provide an example..
Thanks and Regards, Divya
For a Cloud deployment, the url to execute the query is
https://cloudplatform.coveo.com/rest/search. You can pass the query either as a JSON body or through the query string. For example, in your case:
would return the single result with the ID you mentionned.
Of course, you also need to authenticate yourself to the Cloud Platform. Search Tokens indeed are a way to do this, but I'm not sure how that'll behave in a trigger, but it certainly worth trying out. Otherwise you could obtain an API key for your Cloud index, but you'll need to ask our support to enable that particular feature for you. But do try with a search token first.
To pass the search token, the easiest way is to use a query string argument: