# Rest-API Bestellstaus ändern

**URL:** <https://forum.shopware.com/t/rest-api-bestellstaus-andern/20742>\
**Category:** Shopware 3.5\
**Tags:** programming\
**Created:** [12. Juni 2014 um 08:19 UTC](https://forum.shopware.com/t/rest-api-bestellstaus-andern/20742 "2014-06-12T08:19:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [12. Juni 2014 um 08:19 UTC](https://forum.shopware.com/t/rest-api-bestellstaus-andern/20742/1 "2014-06-12T08:19:09Z")

</div>

Hallo und guten Morgen Ich versuche über die REST\_API den Bestellstatus zu ändern. Ich habe mich genau an die ONlinehilfe gehalten. Die REST\_API funktioniert. Nun habe ich aber folgendes Problem: Wenn ich den Bestellstatus ändern möchte erhalte ich folgende Fehlermeldung:

## HTTP: 302

PHP Notice: Use of undefined constant JSON\_ERROR\_NONE - assumed ‘JSON\_ERROR\_NONE’ in Embedded code on line 66PHP Notice: Use of undefined constant JSON\_ERROR\_DEPTH - assumed ‘JSON\_ERROR\_DEPTH’ in Embedded code on line 67PHP Notice: Use of undefined constant JSON\_ERROR\_CTRL\_CHAR - assumed ‘JSON\_ERROR\_CTRL\_CHAR’ in Embedded code on line 68PHP Notice: Use of undefined constant JSON\_ERROR\_SYNTAX - assumed ‘JSON\_ERROR\_SYNTAX’ in Embedded code on line 69

## Could not decode json

PHP Fatal error: Call to undefined function json\_last\_error() in Embedded code on line 72 Der Bestellstatus wird aber korrekt geändert. Source-genau nach Beispiel: class ApiClient { const METHODE\_GET = ‘GET’; const METHODE\_PUT = ‘PUT’; const METHODE\_POST = ‘POST’; const METHODE\_DELETE = ‘DELETE’; protected $validMethods = array( self::METHODE\_GET, self::METHODE\_PUT, self::METHODE\_POST, self::METHODE\_DELETE ); protected $apiUrl; protected $cURL; public function \_\_construct($apiUrl, $username, $apiKey) { $this-\>apiUrl = rtrim($apiUrl, ‘/’) . ‘/’; //Initializes the cURL instance $this-\>cURL = curl\_init(); curl\_setopt($this-\>cURL, CURLOPT\_RETURNTRANSFER, true); curl\_setopt($this-\>cURL, CURLOPT\_FOLLOWLOCATION, false); curl\_setopt($this-\>cURL, CURLOPT\_HTTPAUTH, CURLAUTH\_DIGEST); curl\_setopt($this-\>cURL, CURLOPT\_USERPWD, $username . ‘:’ . $apiKey); curl\_setopt($this-\>cURL, CURLOPT\_HTTPHEADER, array( ‘Content-Type: application/json; charset=utf-8’, )); } public function call($url, $method = self::METHODE\_GET, $data = array(), $params = array()) { if (!in\_array($method, $this-\>validMethods)) { throw new Exception('Invalid HTTP-Methode: ’ . $method); } $queryString = ‘’; if (!empty($params)) { $queryString = http\_build\_query($params); } $url = rtrim($url, ‘?’) . ‘?’; $url = $this-\>apiUrl . $url . $queryString; $dataString = json\_encode($data); curl\_setopt($this-\>cURL, CURLOPT\_URL, $url); curl\_setopt($this-\>cURL, CURLOPT\_CUSTOMREQUEST, $method); curl\_setopt($this-\>cURL, CURLOPT\_POSTFIELDS, $dataString); $result = curl\_exec($this-\>cURL); $httpCode = curl\_getinfo($this-\>cURL, CURLINFO\_HTTP\_CODE); return $this-\>prepareResponse($result, $httpCode); } public function get($url, $params = array()) { return $this-\>call($url, self::METHODE\_GET, array(), $params); } public function post($url, $data = array(), $params = array()) { return $this-\>call($url, self::METHODE\_POST, $data, $params); } public function put($url, $data = array(), $params = array()) { return $this-\>call($url, self::METHODE\_PUT, $data, $params); } public function delete($url, $params = array()) { return $this-\>call($url, self::METHODE\_DELETE, array(), $params); } protected function prepareResponse($result, $httpCode) { echo "

## HTTP: $httpCode

"; if (null === $decodedResult = json\_decode($result, true)) { $jsonErrors = array( JSON\_ERROR\_NONE =\> ‘Es ist kein Fehler aufgetreten’, JSON\_ERROR\_DEPTH =\> ‘Die maximale Stacktiefe wurde erreicht’, JSON\_ERROR\_CTRL\_CHAR =\> ‘Steuerzeichenfehler, möglicherweise fehlerhaft kodiert’, JSON\_ERROR\_SYNTAX =\> ‘Syntaxfehler’, ); echo "

## Could not decode json

"; echo "json\_last\_error: " . $jsonErrors[json\_last\_error()]; echo "  
Raw:  
"; echo "

```
" . print\_r($result, true) . "

```

"; return; } if (!isset($decodedResult[‘success’])) { echo “Invalid Response”; return; } if (!$decodedResult[‘success’]) { echo "

## No Success

"; echo "

" . $decodedResult[‘message’] . "

"; return; } echo "

## Success

"; if (isset($decodedResult[‘data’])) { echo "

```
" . print\_r($decodedResult['data'], true) . "

```

"; } return $decodedResult; } }; $client = new ApiClient(‘[http://shop.aqula.ch/api’,‘userapi’,'HEVgLyZkHTShHNH5yvqAE](http://shop.aqula.ch/api','userapi','HEVgLyZkHTShHNH5yvqAE)’); $client-\>call(‘orders/3479’, ApiClient::METHODE\_PUT, array( ‘orderStatusId’ =\> 2, )); Für jede Hilfe bin ich dankbar! Grüsse Urs

---

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [16. Juni 2014 um 08:40 UTC](https://forum.shopware.com/t/rest-api-bestellstaus-andern/20742/2 "2014-06-16T08:40:28Z")

</div>

Für Hilfe wäre ich sehr dankbar-würde schon gerne wissen was mir diese Fehlermeldung sagen möchte
