Forum Discussion

Inactive User's avatar
Inactive User
6 years ago

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...
  • VikasB's avatar
    VikasB
    6 years ago

    Inactive User 
    Yes, you can make a V2 hit from JS also. But URL will be like this
    For stage

     

    https://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 password

    https://<community_domain>/restapi/vc/authentication/sessions/login