php - Rest API Request invalid request -


still struggling restapi request. following request:

while($erg = odbc_fetch_array($query)){      $count++;      $sql_inner = "select * adadr idadadr = ".$erg['idad']."";     $query_inner = odbc_exec($connection, $sql_inner);     $erg_inner = odbc_fetch_array($query_inner);      $sql_inner_1 = "select * admemo idadmemo = ".$erg['idad']."";     $query_inner_1 = odbc_exec($connection, $sql_inner_1);     $erg_inner_1 = odbc_fetch_array($query_inner_1);      $jsonpayload = json_encode(     ['code' => $erg['kurzcode'],     'shortname' => $erg['kurzcode'],     'classificationtype' => "0",     'iscompany' => "true",     'externalkey' => $erg['idad'],     'website' => $erg_inner['www'],     'federaltaxid' => ' ',     'bankname' => ' ',     'bankaccount' => ' ',     'bankaccountname' => ' ',     'bankcontrolkey' => ' ',     'bankbranch' => ' ',     'bankswift' => ' ',     'bankiban' => ' ',     'iscustomer' => "true",     'custopeningtext' => ' ',     'custclosingtext' => ' ',     'custcreditlimit' => "0",     'custdiscountpercent' => "0",     'custtaxliable' => "true",     'custdunningblock' => "true",     'custdunningblockreason' => ' ',     'custdeliveryblock' => "true",     'custdeliveryblockreason' => ' ',     'custexternalkey' => $erg['idad'],     'issupplier' => "true",     'supopeningtext' => ' ',     'supclosingtext' => ' ',     'supcreditlimit' => "0",     'supdiscountpercent' => "0",     'suptaxliable' => "true",     'supdunningblock' => "true",     'supdunningblockreason' => ' ',     'supdeliveryblock' => "true",     'supdeliveryblockreason' => ' ',     'supexternalkey' => ' ',     'openbalancessales' => "0",     'openbalancespurchase' => "0",     'openbalancetotal' => "0",     'businesspartnergroupid' => ' ',     'currencyid' => ' ',     'salespersonid' => ' ',     'languageid' => ' ',     'regionid' => ' ',     'sectorid' => ' ',     'bankcountryid' => ' ',     'salespaymenttermid' => ' ',     'salespricelistid' => ' ',     'salespaymenttypeid' => ' ',     'purchasepaymenttermid' => ' ',     'purchasepricelistid' => ' ',     'purchasetaxcodeid' => ' ',     'purchasepaymenttype' => ' ',     'parentid' => ' ',     'tokens' => ' ',     'ownerid' => ' ',     'shortdescription' => ' ',     'title' => $erg['name1'],     'isinactive' => "true",     'description' => "".$erg_inner_1['interesse']."".$erg_inner_1['kumemo']."",], json_pretty_print);          $http = new client([         'headers' => ['authorization' => 'bearer ' . $token["access_token"], 'content-length' => strlen($jsonpayload)]     ]);      $response = $http->post('https://test-api.appsolut.at:443/be14/crm/businesspartners?applicationkey=05122123715505505910414822421514420223122224104601322201721602610[...]', $jsonpayload, ['type' => 'application/json']);     print_r($response); 

}

i got structure documentation of api swagger. if try submit post request following response:

cake\network\http\response object ( [_code:protected] => 400 [_body:protected] => {"$id":"1","message":"the request invalid.","modelstate":{"$id":"2","entitytoadd.businesspartnergroupid":["an error has occurred."],"entitytoadd.currencyid":["an error has occurred."],"entitytoadd.salespersonid":["an error has occurred."],"entitytoadd.languageid":["an error has occurred."],"entitytoadd.regionid":["an error has occurred."],"entitytoadd.sectorid":["an error has occurred."],"entitytoadd.bankcountryid":["an error has occurred."],"entitytoadd.salespaymenttermid":["an error has occurred."],"entitytoadd.salespricelistid":["an error has occurred."],"entitytoadd.salespaymenttypeid":["an error has occurred."],"entitytoadd.purchasepaymenttermid":["an error has occurred."],"entitytoadd.purchasepricelistid":["an error has occurred."],"entitytoadd.purchasetaxcodeid":["an error has occurred."],"entitytoadd.parentid":["an error has occurred."],"entitytoadd.ownerid":["an error has occurred."]}} [_xml:protected] => [_json:protected] => [_exposedproperties:protected] => array ( [cookies] => _cookies [headers] => _headers [body] => _body [code] => _code [json] => _getjson [xml] => _getxml ) [_headers:protected] => array ( [cache-control] => no-cache [pragma] => no-cache [content-length] => 910 [content-type] => application/json; charset=utf-8 [expires] => -1 [server] => microsoft-iis/8.0 [x-aspnet-version] => 4.0.30319 [x-powered-by] => asp.net [set-cookie] => arraffinity=f9083e983e049ddfbc317fa7ccfeec62cbe8ceb7f740470e4cd8e8a291cd206c;path=/;domain=test-api.appsolut.at [date] => mon, 27 jul 2015 10:50:56 gmt [connection] => close ) [_cookies:protected] => array ( [arraffinity] => array ( [value] => f9083e983e049ddfbc317fa7ccfeec62cbe8ceb7f740470e4cd8e8a291cd206c [path] => / [domain] => test-api.appsolut.at [name] => arraffinity ) ) [_version:protected] => 1.1 ) cake\network\http\response object ( [_code:protected] => 500 [_body:protected] => {"$id":"1","success":false,"message":"entity not defined","newid":0,"name":null,"exception":null,"brokenrules":null,"hasexception":false,"hasbrokenrules":false} [_xml:protected] => [_json:protected] => [_exposedproperties:protected] => array ( [cookies] => _cookies [headers] => _headers [body] => _body [code] => _code [json] => _getjson [xml] => _getxml ) [_headers:protected] => array ( [cache-control] => no-cache [pragma] => no-cache [content-length] => 160 [content-type] => application/json; charset=utf-8 [expires] => -1 [server] => microsoft-iis/8.0 [x-aspnet-version] => 4.0.30319 [x-powered-by] => asp.net [set-cookie] => arraffinity=f9083e983e049ddfbc317fa7ccfeec62cbe8ceb7f740470e4cd8e8a291cd206c;path=/;domain=test-api.appsolut.at [date] => mon, 27 jul 2015 10:50:58 gmt [connection] => close ) [_cookies:protected] => array ( [arraffinity] => array ( [value] => f9083e983e049ddfbc317fa7ccfeec62cbe8ceb7f740470e4cd8e8a291cd206c [path] => / [domain] => test-api.appsolut.at [name] => arraffinity ) ) [_version:protected] => 1.1 ) cake\network\http\response object ( [_code:protected] => 400 [_body:protected] => {"$id":"1","message":"the request invalid.","modelstate":{"$id":"2","entitytoadd.businesspartnergroupid":["an error has occurred."],"entitytoadd.currencyid":["an error has occurred."],"entitytoadd.salespersonid":["an error has occurred."],"entitytoadd.languageid":["an error has occurred."],"entitytoadd.regionid":["an error has occurred."],"entitytoadd.sectorid":["an error has occurred."],"entitytoadd.bankcountryid":["an error has occurred."],"entitytoadd.salespaymenttermid":["an error has occurred."],"entitytoadd.salespricelistid":["an error has occurred."],"entitytoadd.salespaymenttypeid":["an error has occurred."],"entitytoadd.purchasepaymenttermid":["an error has occurred."],"entitytoadd.purchasepricelistid":["an error has occurred."],"entitytoadd.purchasetaxcodeid":["an error has occurred."],"entitytoadd.parentid":["an error has occurred."],"entitytoadd.ownerid":["an error has occurred."]}} [_xml:protected] => [_json:protected] => [_exposedproperties:protected] => array ( [cookies] => _cookies [headers] => _headers [body] => _body [code] => _code [json] => _getjson [xml] => _getxml ) [_headers:protected] => array ( [cache-control] => no-cache [pragma] => no-cache [content-length] => 910 [content-type] => application/json; charset=utf-8 [expires] => -1 [server] => microsoft-iis/8.0 [x-aspnet-version] => 4.0.30319 [x-powered-by] => asp.net [set-cookie] => arraffinity=f9083e983e049ddfbc317fa7ccfeec62cbe8ceb7f740470e4cd8e8a291cd206c;path=/;domain=test-api.appsolut.at [date] => mon, 27 jul 2015 10:50:58 gmt [connection] => close ) [_cookies:protected] => array ( [arraffinity] => array ( [value] => f9083e983e049ddfbc317fa7ccfeec62cbe8ceb7f740470e4cd8e8a291cd206c [path] => / [domain] => test-api.appsolut.at [name] => arraffinity ) ) [_version:protected] => 1.1 ) cake\network\http\response object ( [_code:protected] => 400 [_body:protected] => {"$id":"1","message":"the request invalid.","modelstate":{"$id":"2","entitytoadd.businesspartnergroupid":["an error has occurred."],"entitytoadd.currencyid":["an error has occurred."],"entitytoadd.salespersonid":["an error has occurred."],"entitytoadd.languageid":["an error has [...] 

i made sure, token , use in post valid token. , tried passing values "0" or "true" without ". tried json encode without json_pretty_print. tried put type "json" or "text/json". not help.

does has idea how start debugging that?


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -