You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by "Matt Gilman (JIRA)" <ji...@apache.org> on 2016/02/20 13:46:18 UTC

[jira] [Commented] (NIFI-1543) Updates through Rest Api with missing Content-Type header results in misleading response

    [ https://issues.apache.org/jira/browse/NIFI-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15155604#comment-15155604 ] 

Matt Gilman commented on NIFI-1543:
-----------------------------------

@frsk - Thanks for your interest in NiFi and reporting this. What it looks like is happening is that when the Content-Type is missing, the request is being interpreted as application/x-www-form-urlencoded. Most endpoints in the REST API are overloaded in the sense that they allow the client to send the request in as a FORM or as an XML or JSON entity. The fact that these additional endpoints do not show up in the documentation is a result of a shortcoming in the tool that generates the documentation and is something we need to address. This issue was reported here [1].

When the JSON request is interpreted as a FORM, none of the parameters (including the revision details) are parsed correctly. This explains the response from your first curl command. To eliminate all confusion, we'll likely be removing the overloaded endpoints in the future release (1.0.0), which is one of the options discussed in [1]. In the meantime, if you explicitly set the Content-Type to indicate the format of your request you shouldn't see this confusing behavior.

Let me know if this helps. Thanks!

Matt

[1] https://issues.apache.org/jira/browse/NIFI-1113

> Updates through Rest Api with missing Content-Type header results in misleading response
> ----------------------------------------------------------------------------------------
>
>                 Key: NIFI-1543
>                 URL: https://issues.apache.org/jira/browse/NIFI-1543
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 0.5.0, 0.4.1
>            Reporter: Fredrik Skolmli
>            Priority: Minor
>              Labels: API, REST
>
> When updating an object, in this case an output port, the HTTP status code 409 Conflict is returned if the Content-Type header is missing. Given the Rest Api documentation stating that 409 is a valid request that may be successfull at a later time, this is misleading.
> Example without the {{Content-Type: application/json}} header.
> {code}
> yes:~/tmp/.tmp.q7s7XMNR% curl 'http://192.168.2.2:8080/nifi-api/controller/revision' 2> /dev/null | python -m json.tool  
> {
>     "revision": {
>         "clientId": "525f9a00-75bc-4cf9-966a-43b204ba7a37",
>         "lastModifier": "anonymous",
>         "version": 29
>     }
> }
> yes:~/tmp/.tmp.q7s7XMNR% curl -v 'http://192.168.2.2:8080/nifi-api/controller/process-groups/22cb7e60-e216-4b31-894b-23402113bf5d/output-ports/e290e44d-2f1e-4c93-bebe-db6b8fcb92f9' -X PUT --data-binary '{"revision":{"version":29,"clientId":"testing"},"outputPort":{"id":"e290e44d-2f1e-4c93-bebe-db6b8fcb92f9","name":"Test","comments":"","groupAccessControl":[],"userAccessControl":["uid=fredrik,ou=People,dc=example,dc=net"],"state":"STOPPED"}}' --compressed                                                                               
> *   Trying 192.168.2.2...
> * Connected to 192.168.2.2 (192.168.2.2) port 8080 (#0)
> > PUT /nifi-api/controller/process-groups/22cb7e60-e216-4b31-894b-23402113bf5d/output-ports/e290e44d-2f1e-4c93-bebe-db6b8fcb92f9 HTTP/1.1
> > Host: 192.168.2.2:8080
> > User-Agent: curl/7.43.0
> > Accept: */*
> > Accept-Encoding: deflate, gzip
> > Content-Length: 238
> > Content-Type: application/x-www-form-urlencoded
> > 
> * upload completely sent off: 238 out of 238 bytes
> < HTTP/1.1 409 Conflict
> < Date: Sat, 20 Feb 2016 00:15:21 GMT
> < Content-Type: text/plain
> < Transfer-Encoding: chunked
> < Server: Jetty(9.2.11.v20150529)
> < 
> * Connection #0 to host 192.168.2.2 left intact
> This NiFi instance has been updated by 'anonymous'. Please refresh to synchronize the view.  
> {code}
> New request with the {{Content-Type}} header.
> {code}yes:~/tmp/.tmp.q7s7XMNR% curl -v 'http://192.168.2.2:8080/nifi-api/controller/process-groups/22cb7e60-e216-4b31-894b-23402113bf5d/output-ports/e290e44d-2f1e-4c93-bebe-db6b8fcb92f9' -X PUT -H "Content-Type: application/json" --data-binary '{"revision":{"version":29,"clientId":"testing"},"outputPort":{"id":"e290e44d-2f1e-4c93-bebe-db6b8fcb92f9","name":"Test","comments":"","groupAccessControl":[],"userAccessControl":["uid=fredrik,ou=People,dc=frsk,dc=net"],"state":"STOPPED"}}' --compressed
> *   Trying 192.168.2.2...
> * Connected to 192.168.2.2 (192.168.2.2) port 8080 (#0)
> > PUT /nifi-api/controller/process-groups/22cb7e60-e216-4b31-894b-23402113bf5d/output-ports/e290e44d-2f1e-4c93-bebe-db6b8fcb92f9 HTTP/1.1
> > Host: 192.168.2.2:8080
> > User-Agent: curl/7.43.0
> > Accept: */*
> > Accept-Encoding: deflate, gzip
> > Content-Type: application/json
> > Content-Length: 238
> > 
> * upload completely sent off: 238 out of 238 bytes
> < HTTP/1.1 200 OK
> < Date: Sat, 20 Feb 2016 00:15:45 GMT
> < Cache-Control: private, no-cache, no-store, no-transform
> < Content-Type: application/json
> < Content-Encoding: gzip
> < Vary: Accept-Encoding, User-Agent
> < Transfer-Encoding: chunked
> < Server: Jetty(9.2.11.v20150529)
> < 
> * Connection #0 to host 192.168.2.2 left intact
> {"revision":{"clientId":"testing","version":30},"outputPort":{"id":"e290e44d-2f1e-4c93-bebe-db6b8fcb92f9","uri":"http://192.168.2.2:8080/nifi-api/controller/process-groups/22cb7e60-e216-4b31-894b-23402113bf5d/output-ports/e290e44d-2f1e-4c93-bebe-db6b8fcb92f9","position":{"x":107.70379100534842,"y":-960.689503119667},"parentGroupId":"22cb7e60-e216-4b31-894b-23402113bf5d","name":"Test","comments":"","state":"STOPPED","type":"OUTPUT_PORT","transmitting":false,"concurrentlySchedulableTaskCount":1,"userAccessControl":["uid=fredrik,ou=People,dc=example,dc=net"],"groupAccessControl":[]}}%                                                                                                                                                                                                                        yes:~/tmp/.tmp.q7s7XMNR% 
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)