Inactive User
7 years agoNot applicable
Can I call a V2 API url in Javascript?
I want to make a call to the Lithium API via Javascript. I know I can do it with V1; can I do with with V2 as well?
Something like
"/restapi/2.0/search?q="SELECT * FROM messages WHERE labels.text IN ('Jupiter')"I want to be able to select messages by tag.id or tag.text (preferably id, if possible), called from Javascript.
Sign in to react to this post
Inactive User
Yes, you can make a V2 hit from JS also. But URL will be like this
For stagehttps://api.stage.lithium.com/community/2.0/<tenant_id>/search?q=SELECT+*+FROM+messages+LIMIT+1&api.pretty_print=true&client-id=xxxxxxxxxx
For production
https://api.lithium.com/community/2.0/<tenant_id>/search?q=SELECT+*+FROM+messages+LIMIT+1&api.pretty_print=true&client-id=LFE0UbsMFc9uDhsZLu03q77KZZjO78svnKTGyT6FDRs=
Client id can be generated from App under Admin > System > API Apps
For authentication, you may need to pass the session id also which can be generated using below API by passing username and passwordhttps://<community_domain>/restapi/vc/authentication/sessions/login