1

I have an Powershell Azure function that receives a (json) string as request body. I need to access the values of XMLA_String, WorkspaceId, and DatasetId in order to set them to variables. Please let me know how

The following body is received:

"{\"XMLA_String\":'{\"refresh\":{\"type\":\"full\",\"objects\":[{\"database\":\"<db>\",\"table\":\"<tab>\"}]}}',
\"WorkspaceId\":'<workspaceid>',
\"DatasetId\":'<datasetid>'}"
0

1 Answer 1

3

Assuming that the line breaks in your sample JSON are just a formatting artifact, it looks like you're getting doubly JSON-encoded data, strangely.

Therefore, try applying ConvertFrom-Json twice (which you've since confirmed solved your problem):

# Sample response received.
$json = @'
"{\"XMLA_String\":'{\"refresh\":{\"type\":\"full\",\"objects\":[{\"database\":\"<db>\",\"table\":\"<tab>\"}]}}',\"WorkspaceId\":'<workspaceid>',\"DatasetId\":'<datasetid>'}"
'@

$json | ConvertFrom-Json | ConvertFrom-Json

The above outputs a [pscustomobject] instance with properties XMLA_String, WorkspaceId, and DatasetId:

XMLA_String                                                                 WorkspaceId   DatasetId
-----------                                                                 -----------   ---------
{"refresh":{"type":"full","objects":[{"database":"<db>","table":"<tab>"}]}} <workspaceid> <datasetid>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.