Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostAgent and XMLRPC - howto? #1361

Closed
nata-lee opened this issue Mar 20, 2016 · 9 comments
Closed

PostAgent and XMLRPC - howto? #1361

nata-lee opened this issue Mar 20, 2016 · 9 comments

Comments

@nata-lee
Copy link

Hello!
Huginn makes my life easier, but some times I'm confused.

I'd like to use xml-rpc with the PostAgent. Specification here: http://xmlrpc.scripting.com/spec.html
But I can't build the sctucture with multiple parameters with the same name. Huginn doesn't let me do this, it's always a json error.
My agent:
{ "post_url": "http://domain/xmlrpc.php", "expected_receive_period_in_days": "1", "content_type": "xml", "method": "post", "no_merge": "true", "xml_root": "methodCall", "payload": { "methodName": "wp.newPost", "params": { "param": { "value": "1" } } }, "headers": {}, "emit_events": "false" }

I need more and multible but how? What am I doing wrong?
Could you help me?

@cantino
Copy link
Member

cantino commented Mar 21, 2016

Hi @nata-lee, I've never actually used true XML-RPC. (As opposed to ajax, which is usually JSON these days.) You may want to have Huginn post to a server that logs your requests, to make sure they look right. http://requestb.in/ could be useful here.

@nata-lee
Copy link
Author

Hi @cantino, thank you for the answer.
Well, I have no problem with XML-RPC then I use curl. And requests and responds are the next step.
I'm confused how to format XML-RPC xmls (and all xmls in general) with huginn interfase and the PostAgent. I tried to form the request as I wrote in the last message, but I can't understand how to get such structure as:

<methodCall>
   <methodName>examples.getStateName</methodName>
   <params>
      <param>
         <value><i4>41</i4></value>
         </param>
      <param>
         <value><user>testname</user></value>
         </param>
      </params>
   </methodCall>

I just need an example.

@cantino
Copy link
Member

cantino commented Mar 26, 2016

The following JSON options are pretty close:

{
  "post_url": "http://requestb.in/123456",
  "expected_receive_period_in_days": "1",
  "content_type": "xml",
  "method": "post",
  "payload": {
    "methodName": "examples.getStateName",
    "params": [
      {
        "value": {
          "i4": "41"
        }
      }
    ]
  },
  "headers": {},
  "emit_events": "false",
  "xml_root": "methodCall"
}

When pointing at a requestbin I made, I got this:

screen shot 2016-03-26 at 4 39 05 pm

@dsander
Copy link
Collaborator

dsander commented Mar 28, 2016

@cantino I think the problem is the to_xml serializer can not generate multiple params elements which have the same parent.

@cantino
Copy link
Member

cantino commented Mar 29, 2016

Wait, what's the problem? Isn't might output what @nata-lee is looking for?

@nata-lee
Copy link
Author

@dsander is quite right. I can't get multiple param in the params.

<params>
 <param>123</param>
 <param>456</param>
</params>

is impossible via huginn interface :( Or I don't know how to get it, so I asked my question.
Maybe any workaround? Now I have to use Shell Command Agent insteed of the PostAgent,and it's some kind of unsecure.

@dsander
Copy link
Collaborator

dsander commented Mar 29, 2016

I don't think that is possible at the moment, but I am planning to change the PostAgent to allow sending arbitrary data which can be formatted using liquid.

dsander added a commit to dsander/huginn that referenced this issue Apr 2, 2016
When `content_type` contains a MIME type and `payload` is not a Hash the string in `payload` will be send as the HTTP
body and `content_type` is send as the `Content-Type` header.

 huginn#1361
@dsander
Copy link
Collaborator

dsander commented Apr 2, 2016

@nata-lee With #1402 merged you will be able generate the XML yourself and setting it in the payload as a string.

dsander added a commit to dsander/huginn that referenced this issue Apr 4, 2016
When `content_type` contains a MIME type and `payload` is not a Hash the string in `payload` will be send as the HTTP
body and `content_type` is send as the `Content-Type` header.

 huginn#1361
@dsander
Copy link
Collaborator

dsander commented Mar 10, 2017

I don't think that will ever be possible with the way to_xml works however the workaround to to manually construct the XML structure should work.

Please feel free to reopen if you need further assistance!

@dsander dsander closed this as completed Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants