Forum Discussion

omygoodness's avatar
7 years ago

Add arbitrary_points / Bonus points using API

Hi,

Is there a way to add/revoke bonus points/arbitrary_points using api?

For example post query?

  • omygoodness-You can achieve this using API V2.  There is no separate call for removing the bonus point, however, you can update it in negative value e.g if you want to revoke 100 points, you can send it in API V2 like this -100. 

     

    PUT /community/2.0/mytenantid/users/42 HTTP/1.1
    Host: api.lithium.com
    Content-Type: application/json
    Cache-Control: no-cache
    
    {
        "data": {
            "type": "user",
            "biography": "I am the walrus.",
            "bonus_points": -100,
        }
    }

    https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&collection=users#fields-bonus_points

     

    • omygoodness's avatar
      omygoodness
      Mentor

      TariqHussain Thank you.

      I am trying to create ajax request with jquery using endpoint but I get errors all the time.

      Can you post simple example how to create such request?

       

      I managed to GET data using:

      https://eu-api.stage.lithium.com/community/2.0/COMMUNITYID/users/3?client_id=CLIENTID

      But how to update some data? Is it possible using http.client.request?

       

      I just tried to use http.client.request with such code:

      <#assign response = http.client.request("https", "my.stage.com", "/api/2.0/users/3").header("Content-Type", "application/json").header("Cache-Control", "no-cache").header("client-id", "CLIENTID").body("{ 'bonus_points':'100' }", "application/json").put()/>
          <#if response.hasError>
              error: ${response.error.message}
              response status: ${response.statusCode}
          <#else>
              response status: ${response.statusCode}
          </#if>

      And I get such errors:

      error: http request not allowed: http client not allowed: hostname-allowed-domains-list-empty
      response status: -1

       

      Update:

      I added domain to whitelist in admin settings but now I get:
      error: html found in response response status: -1