Siri shortcuts rounding number in “Get Contents of URL” POST

爱⌒轻易说出口 提交于 2020-01-15 09:42:29

问题


I am trying to create a iOS 12 Shortcut based on the Gautrain API.

I want to do a POST to the URL https://api.gautrain.co.za/transport-api/api/0/journey/create with the following payload:

{
    "geometry": {
        "coordinates": [
            [
                28.23794,
                -25.74762
            ],
            [
                28.05693,
                -26.10858
            ]
        ],
        "type": "MultiPoint"
    },
    "profile": "ClosestToTime",
    "maxItineraries": 3,
    "timeType": "DepartAfter",
    "only": {
        "agencies": [
            "edObkk6o-0WN3tNZBLqKPg"
        ]
    }
}

I have entered all these details into a "Get Contents of URL" block. For the elements of the "coordinates" arrays I have used "Number".

The problem is that when I track what my phone is sending via mitmproxy, it sends all the information correctly, but the coordinates have been rounded to integers:

{
    "geometry": {
        "coordinates": [
            [
                28,
                -25
            ],
            [
                28,
                -26
            ]
        ],
        "type": "MultiPoint"
    },
    "maxItineraries": 1,
    "only": {
        "agencies": [
            "edObkk6o-0WN3tNZBLqKPg"
        ]
    },
    "profile": "ClosestToTime",
    "timeType": "DepartAfter"
}

For this reason, the request is not giving the desired results.

I have a feeling this may be a bug, but is there something I am missing where I can tell Shortcuts to use the full set of digits?


回答1:


I have found the problem. Since I am in South Africa, the numbers are expected to have commas instead of periods for decimals. I would have loved some feedback in the field that this wasn't a valid number instead of just silently ignoring the decimal.

The solution therefore was to change the "28.23794" in the entry box to "28,23794".

I might also link to postman-echo.com as an excellent tool for debugging these kinds of requests.



来源:https://stackoverflow.com/questions/52455137/siri-shortcuts-rounding-number-in-get-contents-of-url-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!