Re: Simple RESTful API - make a patch
Kearney Taaffe <[email protected]> Thu, 10 Nov 2016 10:00:39 -0800 (PST)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
@Tim, unfortunately, adding the PATCH to the response headers and the
OPTIONS function didn't do anything. I'm still getting the error
line 143, in PATCH
data = cherrypy.request.json
Here's the data I'm sending in for the PATCH request:
PATCH /api/users/123-123-123 HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: localhost:8080
Connection: close
User-Agent: Paw/3.0.12 (Macintosh; OS X/10.12.1) GCDHTTPRequest
Content-Length: 21
{"last_name":"Jones"}
On Thursday, November 10, 2016 at 11:50:14 AM UTC-6, Tim Roberts wrote:
>
> Kearney Taaffe wrote:
>
> I'm making an API in CherryPy. I must admit, it's super easy, and I'd like
> to turn this example into something that the CherryPy community puts on
> it's website as a "how to API"
>
> The problem I'm having is how to handle an HTTP PATCH request. The
> following code fails with the error for HTTP PATCH requests
>
> AttributeError: 'Request' object has no attribute 'json'
>
>
> I've never used the JSON tool, but I can't help but notice this:
>
> cherrypy.response.headers["Access-Control-Allow-Methods"] = (
> 'GET, POST, PUT, DELETE, OPTIONS'
> )
> ...
> def OPTIONS(self):
> return 'Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT'
>
> Neither of those lists include PATCH.
>
> --
> Tim Roberts, [email protected] <javascript:>
> Providenza & Boekelheide, Inc.
>
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.