Error While using REST Api

Hello,

While using REST API for creating Support Ticket From one setup instance to another instance,
I am getting following error while tracing the response.text

File "/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/app.py", line 49, in application response = frappe.api.handle() File "/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/api.py", line 42, in handle return frappe.handler.handle() File "/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/handler.py", line 66, in handle execute_cmd(cmd) File "/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/handler.py", line 72, in execute_cmd method = get_attr(cmd) File "/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/handler.py", line 95, in get_attr method = globals()[cmd] KeyError: u'Support Ticket'


My code for calling REST is

import json
import requests
data = {}
data['raised_by'] = self.raised_by
data['subject']= self.subject
data['status']= self.status
data['company']= self.company

url = 'http://192.168.5.12:7676/api/method/Support Ticket'
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(data) ,headers=headers)
frappe.errprint(response.text)



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/a3e2f5d4-1f6c-4958-b25e-be169dc334b7%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

from https://frappe.io/developers/api/rest_api

I think it should be /api/resource  not /api/method

On Wednesday, August 20, 2014 10:40:58 PM UTC+8, Pranali Khatode wrote:
Hello,

While using REST API for creating Support Ticket From one setup instance to another instance,
I am getting following error while tracing the response.text

File “/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/app.py”, line 49, in application
response = frappe.api.handle()
File “/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/api.py”, line 42, in handle
return frappe.handler.handle()
File “/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/handler.py”, line 66, in handle
execute_cmd(cmd)
File “/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/handler.py”, line 72, in execute_cmd
method = get_attr(cmd)
File “/home/saurabh/Documents/alek/erpnext-bench/apps/frappe/frappe/handler.py”, line 95, in get_attr
method = globals()[cmd]
KeyError: u’Support Ticket’


My code for calling REST is

import json
import requests
data = {}
data[‘raised_by’] = self.raised_by
data[‘subject’]= self.subject
data[‘status’]= self.status
data[‘company’]= self.company

headers = {‘content-type’: ‘application/json’}
response = requests.post(url, data=json.dumps(data) ,headers=headers)
frappe.errprint(response.text)



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8b3e9583-c670-43c0-8a1f-09a3acf92094%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.