[Pharo-dev] Zinc / REST misunderstanding

Nicolas Anquetil nicolas.anquetil at inria.fr
Thu Feb 2 10:51:00 EST 2017


Hi,

I am trying to create a small Redmine wrapper with Zinc, using Redmine 
REST API

And I am having a problem to update issues in redmine from zinc.
In curl, I can do:

curl -v -H "Content-Type: application/json" -X PUT --data-binary '{
   "issue": {
     "subject": "Subject different changed",
     "notes": "The subject was changed changed"
   }
}'  -u anquetil:<mypasswd> http://<theserver>/redmine/issues/430.json

and this updates issue #430 by changing its subject and notes.

For information, the trace given by curl (-v) is:

*   Trying <theserver>...
   % Total    % Received % Xferd  Average Speed   Time Time     Time  
Current
                                  Dload  Upload   Total Spent    Left  Speed
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- 
--:--:--     0* Connected to <theserver> (<theserver>) port 80 (#0)
* Server auth using Basic with user 'anquetil'
 > PUT /redmine/issues/430.json HTTP/1.1
 > Host: <theserver>
 > Authorization: Basic YW5xdWV0aWw6UjNkTTFuMy1wYXNz
 > User-Agent: curl/7.47.0
 > Accept: */*
 > Content-Type: application/json
 > Content-Length: 110
 >
} [110 bytes data]
* upload completely sent off: 110 out of 110 bytes
100   110    0     0  100   110      0    546 --:--:-- --:--:-- 
--:--:--   544< HTTP/1.1 200 OK
< Date: Thu, 02 Feb 2017 12:18:41 GMT
< Server: Apache/2.2.22 (Ubuntu)
< X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.21
< X-Rack-Cache: invalidate, pass
< X-Request-Id: 73f75565...
< X-UA-Compatible: IE=Edge,chrome=1
< Cache-Control: no-cache
< X-Runtime: 0.994081
< Set-Cookie: _redmine_session=BAh7ByIP...; path=/; HttpOnly
< Set-Cookie: autologin=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
< Status: 200
< Content-Length: 0
< Content-Type: application/json; charset=utf-8
<
100   110    0     0  100   110      0    105  0:00:01 0:00:01 
--:--:--   105
* Connection #0 to host <theserver> left intact

The problem is that I cannot replicate that with Zinc:

cont := '{
   "issue": {
     "subject": "Subject different changed",
     "notes": "The subject was changed changed"
   }
}'.
ent := ((ZnHeaders requestHeadersFor: 'http://<theserver>/redmine/' 
asZnUrl )
     contentType: (ZnMimeType main: 'application' sub: 'json')) ;
     contentLength: cont size.

ZnClient new
     beOneShot ;
     entity: ent ;
     username: 'anquetil' password: '<mypasswd>' ;
     put: 'http://<theserver>/redmine/issues/430.json' contents: cont ;
     response.

if I inspect the ZnHeader constructed, it seems to have all headers that 
curl traces except the Authorization: Basic one:

The response of ZnClient is "200 OK", with again the same headers as 
reported by curl

Yet the issue remains unchanged on the redmine server (contrary to curl 
evidently)

Can anyone explain where the error could be ?
Any help will be gladly welcome

nicolas

-- 
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20170202/75c8b9e2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cicgeiiljjcidaam.png
Type: image/png
Size: 25480 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20170202/75c8b9e2/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mjlnpnjhhegjmhnl.png
Type: image/png
Size: 68840 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20170202/75c8b9e2/attachment-0001.png>


More information about the Pharo-dev mailing list