Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Google Maps API

    Posted 06-05-2025 18:46

    eddoner | 2024-09-06 12:17:27 UTC | #1

    Hello, I am trying to execute a Data Action that queries the Google Maps API and returns the CountryCode. The problem I have is that it returns a value for the assigned Code, but with an error.

    Request:

    { "requestUrlTemplate": "https://maps.googleapis.com/maps/api/geocode/json?address=${input.address}&key=XXXXX", "requestType": "GET", "headers": {}, "requestTemplate": "${input.rawRequest}" }

    Response:

    { "translationMap": { "CountryCode": "$.results[0].addresscomponents[?(@.types[0] == 'country')].shortname" }, "translationMapDefaults": {}, "successTemplate": "${CountryCode}" }

    Input:

    { "type": "object", "required": [ "address" ], "properties": { "address": { "type": "string" } }, "additionalProperties": true }

    Output:

    { "type": "object", "properties": { "CountryCode": { "type": "string" } }, "additionalProperties": true }

    Output transformation returns correct value but still error

    { "message": "JSON failed output schema validation for the following reasons: instance type (array) does not match any allowed primitive type (allowed: [\"object\"])", "code": "invalid.schema", "status": 400, "messageParams": {}, "contextId": "6a54d6be-3dfb-4462-8f54-1946146609d6", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }

    What could be causing this error? Thanks!


    Jason_Mathison | 2024-09-06 14:13:40 UTC | #2

    Your output schema is configured to be an object with a CountryCode in it, so something like: { "CountryCode" : "DE" }

    However, the action is returning an array with a CountryCode in it: [ "CountryCode" : "DE" ]

    Note that {} is for an object, but [] is for an array.

    You should be able to update your output contract to get this resolved.

    --Jason


    eddoner | 2024-09-06 15:25:04 UTC | #3

    Hi, Thank you very much for qucik replay. I cannot find correct output schema. Anything I tried always give same error. Maybe that will help, below raw API Response.

    { "results": [ { "addresscomponents": [ { "longname": "Berlin", "shortname": "Berlin", "types": [ "locality", "political" ] }, { "longname": "Kreisfreie Stadt Berlin", "shortname": "Kreisfreie Stadt Berlin", "types": [ "administrativearealevel3", "political" ] }, { "longname": "Berlin", "shortname": "BE", "types": [ "administrativearealevel1", "political" ] }, { "longname": "Germany", "shortname": "DE", "types": [ "country", "political" ] } ], "formattedaddress": "Berlin, Germany", "geometry": { "bounds": { "northeast": { "lat": 52.6754542, "lng": 13.7611175 }, "southwest": { "lat": 52.338234, "lng": 13.088346 } }, "location": { "lat": 52.52000659999999, "lng": 13.404954 }, "locationtype": "APPROXIMATE", "viewport": { "northeast": { "lat": 52.6754542, "lng": 13.7611175 }, "southwest": { "lat": 52.338234, "lng": 13.088346 } } }, "placeid": "ChIJAVkDPzdOqEcRcDteW0YgIQQ", "types": [ "locality", "political" ] } ], "status": "OK" }


    system | 2024-10-07 15:25:38 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: 28934