Missing possibility to make web request of type PATCH

Former Member
Former Member
Hi,
I'm developing an application which uses WebAPI from an external provider. If I'm correct currently, there is a possibility to call WebAPI (makeWebRequest method) only with HTTP methods GET, POST, PUT and DELETE (HTTP_REQUEST_METHOD_* constants in Toybox.Communications. Unfortunately some functionalities on this WebAPI are available only by requests of type PATCH.

Can somebody help with that?
  • While not entirely relevant to the actual question, it does seem worth noting that PATCH is not yet standard HTTP. There is a proposal with known errata, but no standard (see RFC 5741[/i]).

    This is not possible to do directly given the current makeWebRequest/makeJsonRequest methods. The best that I can imagine is to run a service that reformats the request as you need. i.e., you send a POST request with a special header/parameter to indicate the service should perform the request using PATCH..

    var params = {
    "method" => "PATCH",
    // ...
    }

    Communications.makeWebRequest(url, params, options, callback);


    The service would see this parameter (or header), strip it from the parameters, perform the original request with the requested HTTP method, and return the result.

    This may seem like a lot of work, and it may be, but in my experience having the intermediary web service is useful. It can be used as a simple injection point for debug code (log requests while testing), and it can be useful if the original service sends large responses with data that you do not need. The BLE link to devices is slow, and if you can cut out data before it hits BLE, you will be saving yourself quite a bit of time.



    Travis
  • Former Member
    Former Member over 7 years ago
    I'm surprised that PATCH is not a standard as it's in common use in many APIs.

    Thanks for a hint with proxy API.
  • While not entirely relevant to the actual question, it does seem worth noting that PATCH is not yet standard HTTP. There is a proposal with known errata, but no standard (see RFC 5741[/i]).

    This is not possible to do directly given the current makeWebRequest/makeJsonRequest methods. The best that I can imagine is to run a service that reformats the request as you need. i.e., you send a POST request with a special header/parameter to indicate the service should perform the request using PATCH..


    If I understand it correctly, the PATCH was proposed in 2010, and proposal hasn't been accepted since then. But recently more and more APIs have been utilizing the PATCH. Isn't it enough justification to include it into Toybox.Communications supported methods?