Advertisement
konradb90

create-rack

Feb 12th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. /**
  2.  * Endpoint URL
  3.  */
  4. $url = url('api/v2/rack');
  5.  
  6. /**
  7.  * First Admin API Key - you should enter your own user api key
  8.  */
  9. $apikey = \User::admins()->first()->apikey->key;
  10.  
  11. $client = new \GuzzleHttp\Client();
  12.  
  13. try {
  14.     $response = $client->request('POST', $url, [
  15.         'headers' => [
  16.             'Accept' => 'application/json',
  17.             'apikey' => $apikey
  18.         ],
  19.         'json' => [
  20.             'data' => [
  21.                 'name' => 'Test Rack 1',
  22.                 'floor_id' => 4,
  23.                 'location_id' => 1,
  24.                 'units_number' => 10
  25.             ],
  26.         ]
  27.     ]);
  28.  
  29.     $stream = \GuzzleHttp\Psr7\stream_for($response->getBody());
  30.  
  31.     d($stream->getContents());
  32. } catch (\Exception $e) {
  33.     d($e->getMessage());
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement