Hi All!
I’m using the PHP Library and until now I had no problem with this.
I have a lot of external services who consume the values from my erpnext.
The point is that now that I’m needing to insert values in the system I’m having problems!
I tried to insert data for one of my doctypes and I recived the follow information.
I would like to have this solution ASAP because I need it to proceed with my system.
Thank you!
object(FrappeClient)#1 (12) {
[“errorno”]=>
int(0)
[“error”]=>
NULL
[“body”]=>
string(7259) "
<link rel="shortcut icon"
href="/assets/erpnext/images/favicon.png"
type="image/x-icon">
<link rel="icon"
href="/assets/erpnext/images/favicon.png"
type="image/x-icon">
<link type="text/css" rel="stylesheet" href="/assets/frappe/css/bootstrap.css">
<link type="text/css" rel="stylesheet" href="/assets/css/frappe-web.css">
<link type="text/css" rel="stylesheet" href="/assets/erpnext/css/website.css">
<link type="text/css" rel="stylesheet" href="/website_theme.css"><script>
window.frappe = {};
frappe.ready_events = [];
frappe.ready = function(fn) {
frappe.ready_events.push(fn);
}
window.dev_server = 0;
</script>
<li class="shopping-cart hidden">
<div class="cart-icon">
<a class="dropdown-toggle" href="#" data-toggle="dropdown" id="navLogin">
Cart <span class="badge-wrapper" id="cart-count"></span>
</a>
<div id="cart-overlay" class="dropdown-menu shopping-cart-menu"></div>
</div>
</li>
<!-- post login tools -->
</div>
</div>
</nav></header>
<div class="hero-and-content">
<div data-html-block="hero"></div>
<div class="container">
<div class="page-content without-sidebar">
<div class="page-content-wrapper">
<div class="row page-head">
<div class='col-sm-12'>
</div>
<div class="col-sm-8 col-xs-6">
</div>
<div class="col-sm-4 col-xs-6">
</div>
</div>
<div class="page_content">
.hero-and-content {
background-color: #f5f7fa;
}
.page-card {
max-width: 640px;
}
Traceback (most recent call last): File "/home/frappe/benches/bench-2017-11-08/apps/frappe/frappe/app.py", line 62, in application response = frappe.api.handle() File "/home/frappe/benches/bench-2017-11-08/apps/frappe/frappe/api.py", line 114, 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
<div><a href='/' class='btn btn-primary btn-sm'>
Home</a></div>
Status: 500
</div>
</div></div>
<div><footer class="web-footer">
<section class="footer-links">
<div class="container">
<div class="row">
<div class="col-sm-6 text-left">
</div>
<div class="col-sm-6 text-right">
</div>
</div>
<div class="row footer-bottom-line">
<div class="text-muted small col-sm-6 col-xs-12">
</div>
<div class="text-muted small col-sm-6 col-xs-12
text-right footer-powered">
<a href="https://erpnext.com?source=website_footer" target="_blank" class="text-muted">
Powered by ERPNext</a>
</div>
</div>
</div>
</section>
<!-- js should be loaded in body! -->
<script type="text/javascript"
src="/assets/frappe/js/lib/jquery/jquery.min.js"></script>
<script type="text/javascript"
src="/assets/js/frappe-web.min.js"></script>
<script type="text/javascript" src="/website_script.js"></script>
<script type="text/javascript" src="/assets/js/erpnext-web.min.js"></script>
<script>frappe.csrf_token = "None";</script></body>
"
["header"]=>
array(23) {
["url"]=>
string(55) "https://mlintercambios.erpnext.com/api/resource/ML Lead"
["content_type"]=>
string(24) "text/html; charset=utf-8"
["http_code"]=>
int(500)
["header_size"]=>
int(511)
["request_size"]=>
int(315)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0.862987)
["namelookup_time"]=>
float(2.8E-5)
["connect_time"]=>
float(0.170764)
["pretransfer_time"]=>
float(0.523655)
["size_upload"]=>
float(0)
["size_download"]=>
float(7259)
["speed_download"]=>
float(8411)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(7259)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0.862885)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(13) "51.15.135.139"
["certinfo"]=>
array(0) {
}
}
["is_auth"]=>
bool(true)
["_auth_url":"FrappeClient":private]=>
string(51) "https://mlintercambios.erpnext.com/api/method/login"
["_api_url":"FrappeClient":private]=>
string(48) "https://mlintercambios.erpnext.com/api/resource/"
["_cookie_file":"FrappeClient":private]=>
string(10) "cookie.txt"
["_auth":"FrappeClient":private]=>
array(2) {
["usr"]=>
string(23) "vitorgvieira1@gmail.com"
["pwd"]=>
string(8) "guizo123"
}
["_basic_auth":"FrappeClient":private]=>
array(0) {
}
["_curl_timeout":"FrappeClient":private]=>
int(30)
["_limit_page_length":"FrappeClient":private]=>
int(20)
}
MY PHP code is the following
<?php
/**
* FrappeClient-PHP Sample Script
*
*/
require(dirname(__FILE__).'/FrappeClient.php');
try{
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: *");
$client = new FrappeClient();
$result = $client->insert(
"ML Lead"
,array(
"vendedor" => "vitorgvieira1@gmail.com"
)
);
var_dump($result);
}catch(Exception $e){
var_dump($e);
}
set_error_handler(function ($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});