Ad Widget

Collapse

API returing code":-32600,"message":"Invalid Request.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ketanb81
    Junior Member
    • Dec 2015
    • 4

    #1

    API returing code":-32600,"message":"Invalid Request.

    Hi,

    I am trying to run following API request but keep getting 'Invalid Request'


    curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"host.create","params": {"host":"test_apihost","interfaces":[{"type":1,"main":1,"useip":1,"ip":"192.168.0.1","d ns":"domain.ru","port":"10050"}],"groups":[{"groupid":"5"}],"templates":[{"templateid":"10130"}],},"auth":"11955c178d18779be5241d61b8dc1a6c","id": 1}' http://<ip>/zabbix/api_jsonrpc.php

    HTTP/1.1 200 OK
    Date: Thu, 21 Jan 2016 20:35:17 GMT
    Server: Apache/2.4.6 (CentOS) PHP/5.4.16
    X-Powered-By: PHP/5.4.16
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Headers: Content-Type
    Access-Control-Allow-Methods: POST
    Access-Control-Max-Age: 1000
    Content-Length: 124
    Content-Type: application/json

    {"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request.","data":"JSON-rpc version is not specified."},"id":null}



    Any idea why I keep getting this error even though JSON-rpc verison is defined.


    thanks
  • ingus.vilnis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2014
    • 908

    #2
    Hi,

    Were you able to log in with API successfully? Did you grab the authentication string from the response?

    If so, then there might be a slight syntax error.
    Please carefully double check that and maybe remove some params for initial tests.



    Best Regards,
    Ingus

    Comment

    • ketanb81
      Junior Member
      • Dec 2015
      • 4

      #3
      Once I typed the statement manually, it worked.


      Thanks

      Comment

      Working...