project-flogo / contrib

Core Flogo activities, triggers and functions that are useful across the various event-driven action types.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REST Invoke - Path and Query Params not working

akpuvvada opened this issue · comments

Below is the Rest Invoke Activity definition. I changed the key for security.

I am getting below error when I try to run it.

2019-11-27T16:14:26.909-0500    INFO    [flogo.activity.log] -  404 -> {"Code":"404","Message":"Not found","Reference":"/currentconditions/v1?apikey=95df38db964c4236936b1e894ad2232f","Exception":null}

The same mapping is working fine when I use in logger and getting json logged.

Mapping: "=string.concat('{\"zipC\": \"', $flow.CityCode_Input, '\"}')"

Log Entry: 2019-11-27T16:14:26.722-0500 INFO [flogo.activity.log] - '{"zipC": "70604"}' - HostID [3758ec316bc59a057d4364336a20b3bc], HostName [Lambda_GET_WeatherLimit_POC], Activity [Log_Request]

{
            "id": "rest_3",
            "name": "AccuWeather_GET_RESTInvoke",
            "description": "Invokes a REST Service",
            "activity": {
              "ref": "#rest",
              "input": {
                "pathParams": "=string.concat('{\"zipC\": \"', $flow.CityCode_Input, '\"}')",
                "queryParams": "=string.concat('{\"apikey\": \"', 'N1KaG63pxFWtIQRcZuKX9', '\"}')"
              },
              "settings": {
                "uri": "http://dataservice.accuweather.com/currentconditions/v1/:zipC?",
                "method": "GET"
              }
            }
          }

The "pathParams" and "queryParams" expects input to be of type Params i.e. map[string]string in go terms. What you are passing in is just type string . So you just be able to do

{
   "pathParams":{\"zipC\":$flow.CityCode_Input}
}

@lixingwang this would be correct mapping, right ?

@skothari-tibco No, it will not work. In this kind of cases, we should use object mapping.
@akpuvvada Please change the mapping to below and it should work.

{
  "input": {
    "pathParams": {
      "mapping": {
        "zipC": "=$flow.CityCode_Input"
      }
    },
    "queryParams": {
      "apikey": "N1KaG63pxFWtIQRcZuKX9"
    }
  }
}

Refer to mapping doc: https://tibcosoftware.github.io/flogo/development/flows/mapping/

@lixingwang ,

It did not work. I am getting same error.

Also, the documentation for Rest Invoke activity shows the data should be given as below and it is also throwing error saying the Path Parameter is not defined.

"input": {
      "params": { "id": "1234"}
    }

Not sure what I am doing wrong.

Also, it works if I give the full URL without Path/Query parameters (hard-code the values).
The Query parameters are working either way. Only Path parameters not working.

Can you remove the ‘?’ from the end of the URI.

Thanks Frank. That worked.