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
Memorable Member
Memorable Member

Hello,

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

View solution in original post

2 REPLIES 2
Mike8
Memorable Member
Memorable Member

Hello,

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

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,345)