Egill_Palsson | 2020-10-16 10:54:38 UTC | #1
First of let me appologise if this is a stupid noob question, but I have been trying to get this to work for some time now without luck :frowning: I have two questions/problems:
Here is a response from my webservice, and all I am really trying to to is fetching two values from there, the Name and SSN: { "PhoneLogin2Result": { "Cert": { "RawData": [ 48, 68 ] }, "CompanyCert": false, "Country": "IS", "Device": 0, "IssuerComp": "Audkenni hf.", "IssuerName": "Fullgilt audkenni", "IssuerSSN": "5210002790", "Name": "Egill Árni Pálsson", "Ou": "20190306033908", "SSN": "1202775459", "Serial": "1A0351", "Type": 0, "Valid": true, "ValidFrom": "/Date(1551886840000+0000)/", "ValidTime": true, "ValidTo": "/Date(1709739639000+0000)/" }, "outStatus": { "Message": "Response decoded successfully.", "Result": 0, "StatusCode": "00" } } For some reason the results are always empty.......or look empty. Using JASONPath I am able to to the selections needed in other platforms, but I am having a hard time wrapping my head arround how to actually do it in GCloud Actions. probably has to do with my lack of understanding OutputContract relation to Response(under Configuration) I did put the following in Translation map, and I can see when doing a Test, that it gets selected, but I am lost when it comes to actually assigning it. I have also followed the instructions found here https://www.youtube.com/watch?v=o4L6qOqWKdY but I don't get my fields populated :frowning: { "translationMap": { "Name": "PhoneLogin2Result.Name", "Kennitala": "PhoneLogin2Result.SSN" }, "translationMapDefaults": {}, "successTemplate": "${rawResult}" }
Again, if this sounds elementary, it is, so if it does not belong here please throw it out.
Best regards, and thanks
ChrisDibble | 2020-10-16 14:10:30 UTC | #2
Hi Egill,
You were on the right path. In the translation map, we use JSONPath notation to extract data from the raw response from the web service into variables. Then, we use those variables in the successTemplate to make the data action return that data.
In your case, your translation map paths were correct, but missing the leading $. that's needed for JSONPath. Then you'd need to use those in your successTemplate. Try using this response config to get you started.
{ "translationMap": { "nameVar": "$.PhoneLogin2Result.Name", "ssnVar": "$.PhoneLogin2Result.SSN" }, "translationMapDefaults": {}, "successTemplate": "{ \"name\": ${nameVar}, \"ssn\": ${ssnVar}}" }
PS: Since you are processing sensitive data, do not forget to mark your data action as secure on the summary tab.
-Chris
Egill_Palsson | 2020-10-16 18:27:15 UTC | #3
ChrisDibble, post:2, topic:9099
{ \"name\": ${nameVar}, \"ssn\": ${ssnVar}}
Thanks a lot Chris, finally a success!!
I am wondering why it is made to look so much simpler in the video :) Because this is defnitely not something I would have stumbled upon myself :slight_smile: Is this only because I am using JSONPath? Or could this have been solved in another way?
Thanks again for your help, it is much appreciated! :slight_smile:
PS: thanks for the advice on sensitive data, it is good to be aware of. But in this case, the ssn is public record in Iceland, so nothing is being sent out that isn't already available to anyone :)
system | 2020-11-16 16:09:09 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 9099