Project

General

Profile

redmine client

Added by Zdravko Balorda about 10 years ago

I need to make a Redmine plugin client. I use httpclient interface and I'm trying an example from wiki pages:

# Request with invalid or missing attributes
POST /users.xml
<user>
  <login>john</login>
  <lastname>Smith</lastname>
  <mail>john</mail>
</user>

but it keeps saying:
NoMethodError (undefined method `[]' for nil:NilClass):
  app/controllers/users_controller.rb:89:in `create'

Obviously I don't know how to stash xml data into a POST call to be understood as params. Is it a simple request body?
clnt = HTTPClient.new
extheader = { 'X-Redmine-API-Key' => '77a29e67432f0984d6747a7de05e0e09d2347a99', 'Content-Type:' => 'application/xml' }
body = "<user> <login>john</login> <lastname>Smith</lastname> <mail>john</mail></user>" 

uri = 'http://redmine.mks:3000/users.xml'
res = clnt.post(uri, body, extheader)

Thank you for helping me.
Regards, Zdravko


Replies (1)

RE: redmine client - Added by Zdravko Balorda about 10 years ago

Sorry:
Don't put colon ":" into Content-Type!

    (1-1/1)