cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

CUSTOM CONNECTOR: Help with JSON Request (or Response?)

Man! Custom Connectors can get confusing to implement. I'm wrapped around the wheel and could use your input. 

Custom Connector Specifics:

Method: POST

Request:

 

{
  "geocode": {
    "lon": -76.1760973855,
    "lat": 43.302601891152
  },
  "location_id": "",
  "start_time": "2018-07-01T12:00:00Z",
  "end_time": "2018-07-01T18:00:00Z",
  "timestep": 60,
  "fields": [
  	
    {
        "name": "temp",
        "units": "C"
        },
        {
        "name": "feels_like",
        "units": "C"
        },
        {
        "name": "dewpoint",
        "units": "C"
        },
        {
        "name": "wind_speed",
        "units": "m/s"
        },
        {
        "name": "wind_gust",
        "units": "m/s"
        },
        {
        "name": "baro_pressure",
        "units": "kPa"
        },
        {
        "name": "visibility",
        "units": "km"
        },
        {
        "name": "precipitation",
        "units": "mm/hr"
        },
        {
        "name": "cloud_cover",
        "units": "%"
        },
        {
        "name": "cloud_ceiling",
        "units": "m"
        },
        {
        "name": "cloud_base",
        "units": "m"
        },
        {
        "name": "humidity",
        "units": "%"
        },
        {
        "name": "wind_direction",
        "units": "degrees"
        },
        {
        "name": "precipitation_type"
        },
        {
        "name": "sunrise"
        },
        {
        "name": "sunset"
        }
  ]
}

Response:

[
    {
        "lat": 42.30260171891152,
        "lon": -71.17609710203855,
        "temp": {
            "value": 25.56,
            "units": "C"
        },
        "feels_like": {
            "value": 25.56,
            "units": "C"
        },
        "dewpoint": {
            "value": 20.13,
            "units": "C"
        },
        "wind_speed": {
            "value": 0.45,
            "units": "m/s"
        },
        "wind_gust": {
            "value": 2.23,
            "units": "m/s"
        },
        "baro_pressure": {
            "value": 101.384,
            "units": "kPa"
        },
        "visibility": {
            "value": null,
            "units": "km"
        },
        "precipitation": {
            "value": 0,
            "units": "mm/hr"
        },
        "cloud_cover": {
            "value": null,
            "units": "%"
        },
        "cloud_ceiling": {
            "value": null,
            "units": "m"
        },
        "cloud_base": {
            "value": null,
            "units": "m"
        },
        "humidity": {
            "value": 72,
            "units": "%"
        },
        "wind_direction": {
            "value": 275,
            "units": "degrees"
        },
        "precipitation_type": {
            "value": "none"
        },
        "sunrise": {
            "value": "2018-07-01T09:11:52.000Z"
        },
        "sunset": {
            "value": "2018-07-02T00:25:08.000Z"
        },
        "observation_time": {
            "value": "2018-07-01T12:00:00.000Z"
        }
    }
]

All headers are in place and the Test results look great.

 

The Problem:

When trying to use the Custom Connector in my app:

 

ClearCollect(
    colWeather,
    APIRequest.WeatherApi(
        {
            apikey:"my-key-is-redacted",
            accept:"application/json",
            'Content-Type':"application/json",
            geocode:
                {
                    lon: Value(longitude_input.Text),
                    lat: Value(latitude_input.Text)
                },
            location_id: " ",
            start_time: DateTimeValue(startTime_zulu.Text),
            end_time:  DateTimeValue(endTime_zulu.Text), 
            timestep:60,
            fields:
                [
                    {
                        name: temp, units: F
                    }
                ]
        }
    )
)

I cannot get the fields parameter to be accepted! I've tried every JSON Table syntax possible including:

 

  • [{name: temp, units: F}]
  • {[{name:temp, units:F}]}
  • [{"name":temp, "units":F}]
  • [{"name":"temp","units":"F"}]
  • etc.

Leaving the fields table out of the request brings back all results but in Metric units. To get Imperial, I need to specify each field name and unit type.

The errors I'm receiving include:

"Missing column. Your formula is missing a column 'name' with type "Text".
"Invalid argument type. Expecting a table value, but of a different schema."

 

There are NO OTHER errors in the query except the fields portion. 

2018-10-17_23-43-43.png2018-10-17_23-48-23.png

 

Can anyone spot what I'm missing?

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Mike8
Solution Sage
Solution Sage

Hello,

Can you try instead of [{name: "temp", units: "F"}] --> Table({name: "temp", units: "F"})

View solution in original post

2 REPLIES 2
Mike8
Solution Sage
Solution Sage

Hello,

Can you try instead of [{name: "temp", units: "F"}] --> Table({name: "temp", units: "F"})

View solution in original post

ericonline
Community Champion
Community Champion

@Mike8

This is why I love the PowerApps community! Your solution worked great. 

 

Thank you very much 🙂

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,211)