Problem with string value

Asked

Viewed 39 times

0

I’m using a Microsofot Graph API to get some data and I need to use one of the values it returns to me to do an UPDATE.

The problem is that the returned value has quotes and bars.

Through GRAPH EXPLORES (a graphical interface for testing requests) an example of value is:

"@odata.etag": "W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBARCc=\""

When I use the API via javascript the value returned already becomes:

"@odata.etag": "W/"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBARCc=""

This value returned I need to use in a request header:

"If-Match": "W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBARCc=\"",

Spelling works, but using the variable returned from javascript does not work, says that If-Match is invalid.

Any idea how to get around this problem?

  • You use a variable, like: "If-Match": variavel,, where the value of variavel should be "W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBARCc=\""?

  • Exactly @Sam

  • Try escaping all double quotes: variavel = variavel.replace(/"/g, '\\"');

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.