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 ofvariavel
should be"W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBARCc=\""
?– Sam
Exactly @Sam
– Joao Paulo
Try escaping all double quotes:
variavel = variavel.replace(/"/g, '\\"');
– Sam