Update Glance from request


#1

I am not sure the proper way to send my glance update request.

I am using node and I have something like this

  const uri = `${apiBaseUrl}/site/${cloudId}/conversation/${conversationId}/app/module/chat:glance/${key}/state`
        options = {
          uri: uri,
          method: 'POST',
          headers: {
            authorization: 'Bearer ' + accessToken,
            'cache-control': 'no-cache'
          },
          json: {
            label: 'test',
            metadata: {}
          }
        }

        request(options, function(err, response, body) {
          callback(err, body)
        })

It does not complain but nothing comes back
The part I am most unsure about is the json payload

  json: {
            label: 'test',
            metadata: {}
          }

I know I am missing something obvious and I can update using curl but I am not sure what I am doing wrong in this case.


#2

Hi @JonB,
If your using the npm request library then I think I see your problem. Everything is perfect, but the json property in your options is a boolean field and the method needs to be a ‘PUT’. Your options should look like this

options = {
          uri: uri,
          method: 'PUT',
          headers: {
            authorization: 'Bearer ' + accessToken,
            'cache-control': 'no-cache'
          },
          json:true,
          body: {
            label: 'test',
            metadata: {}
          }
        }

Thant should then tell Stride to update the glance to say “test” on hover over.


#3

Wow that was so subtle I would have have caught it and there was no doc to support the fact that the message needed to be wrapped in body {}. It worked and you are a rock star. Thanks!