Adding serial number via api (php + FrappeClient)

Hello,
I’m trying to integrate erpnext for warehouse management to our own instrument register hosted at our local server. I’m using php and frappe client library.
The problem is I don’ know how to add new “Serial No” via api call.
I have the client configured and I can login and read user info, search serial numbers etc…

    $client = new FrappeClient();
    $result = $client->get(
    					"User"
    					,"myemail"
    				);

What parameters should I use to create new serial no?

I’m getting http error 500 with following parameters:

$result = $client->insert(
			"Serial No",
			array(
				"name" => "SNR4444",
				"serial_no" => "SNR4444",
				"item_code" => "OurProductCode",
				"company" => "OUR COMPANY"
			)
);

Any tips are welcome!

Update:
I tried adding “Person” via api to keep things simple.
now I got the following error

Server Error

Traceback (most recent call last):
  File "/home/frappe/benches/bench-2016-12-27/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/benches/bench-2016-12-27/apps/frappe/frappe/api.py", line 115, in handle
    data = json.loads(frappe.local.form_dict.data)
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

in php curl I encode the fileds like this:

curl_setopt(
 $ch
,CURLOPT_POSTFIELDS
,array('data' => json_encode($params['data']) )
);

This array seems like (in my opinion) correct data format to be sent:

array(1) { ["data"]=> string(21) "{"first_name":"Hepa"}" }

I’m not sure how to debug json parse errors detected by eprnext.com server…

Any suggestions how to proceed with debugging?
Thanks!

Are you using this? GitHub - tmimori/How-to-connect-to-ERPNext-v5-API-with-PHP5: How to connect to ERPNext v5 API with PHP 5

Hello,
That is the one!
Just noticed that my curl is version 7.14 and requirement is 7.30. Maybe this will cause encoding etc. issues. I’ll update and then return.

Ok,
now I tested the script in another server (still windows apache), but with more recent version of php/curl (7.49.1).
I’m still getting the same error response.

Has anyone ever managed to get php/curl POST json data calls to ErpNext REST api from Windows / windows server to work?

Try debugging here

Thanks,
sorry, I don’t have the code installed. I use erpnext.com hosted server. Our own server is windows 2008 r2 apache and I’m trying to access the rest interface from PHP code. I can login and read / search but cannot send any new items. The JSON is not accepted.

hi @hexa_dlfn , i want to know, can you send new item from erpnext to other php website for now? have you solved it?

Pls someone tell me.