Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
466 views
in Technique[技术] by (71.8m points)

azure - Quotes and special character issue in set and append variable in ADF

I'm trying to prepare a variable value using set and append variable that needs to be passed to the request body of the copy activity to fetch the data from API. I need to do lookup of 100 values from DB at a time and form a array of values but " (quote) value is getting appended in the starting, end and in between of values due to which the copy activity is failing. I'm trying for the first two values as of now. "["{\"RIC\":{\"Value\":\"FHN.N\"}}","{\"RIC\":{\"Value\":\"0142.HK\"}}"]" this is the final variable output that I'm getting, I've removed the additional (slashes) using @replace(string(variables('RIC')),'','') and the output was - "["{"RIC":{"Value":"FHN.N"}}","{"RIC":{"Value":"0142.HK"}}"]" due to the " quotes in between the two RIC values and in between }] in the starting and at the end it's failing. If I can get the output as "[{"RIC":{"Value":"FHN.N"}},{"RIC":{"Value":"0142.HK"}}]" it would solve the issue as I tried passing this manually.

Request body passed in copy activity - "{"GetSignificantDevelopments_Request_1":{"FindRequest":{"CompanyIdentifiers_typehint":["CompanyIdentifiers","CompanyIdentifiers"],"CompanyIdentifiers":["{"RIC":{"Value":"FHN.N"}}","{"RIC":{"Value":"0142.HK"}}"],"StartDate": "2021-01-05T00:00:00","EndDate": "2021-01-06T00:00:00","Significance": "1 2 3","MaxNumberOfItems": 100}}}", - this is failing

manually tried successful request body - "{"GetSignificantDevelopments_Request_1":{"FindRequest":{"CompanyIdentifiers_typehint":["CompanyIdentifiers","CompanyIdentifiers"],"CompanyIdentifiers":[{"RIC":{"Value":"FHN.N"}},{"RIC":{"Value":"0142.HK"}}],"StartDate": "2021-01-05T00:00:00","EndDate": "2021-01-06T00:00:00","Significance": "1 2 3","MaxNumberOfItems": 100}}}",

question from:https://stackoverflow.com/questions/65599638/quotes-and-special-character-issue-in-set-and-append-variable-in-adf

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The other way would be to use Replace function to replace all unwanted characters from the variable like : @replace(string(variables('RIC')),'','') where is just one of the characters. You can keep on concatenating replace functions to replace other characters and achieve your output. Hope this would be helpful :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...