# Kunde über Api erstellen

**URL:** <https://forum.shopware.com/t/kunde-uber-api-erstellen/58520>\
**Category:** Programmierung\
**Created:** [12. März 2019 um 12:39 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520 "2019-03-12T12:39:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtuzth](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rtuzth](https://forum.shopware.com/u/rtuzth)\
**Post date:** [12. März 2019 um 12:39 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/1 "2019-03-12T12:39:35Z")

</div>

Guten Tag,

ich weiß, das Thema wurde schon besprochen und ich habe die Suchfunktion genutzt, leider konnten die bestehenden Threads zu dem Thema mein Problem nicht lösen. Ich versuche mich an einem kleinen Wrapper für die Rest-Api in Ruby, der den es noch auf GitHub gibt ist leider vollständig veraltet. Dies ist mein Code:

```
require 'httparty'
require 'pp'

class SwApiWrapper

  include HTTParty
  base_uri 'localhost/shopware/api'
  digest_auth 'demo', 'myApiKey'

  def get_orders
    self.class.get('/orders')['data']
  end

  def post_order(order)
    self.class.post(order)
  end

  def get_customers
    self.class.get('/customers')['data']
  end

  def post_customer()
    self.class.post('/costumers', :body => {'email' => 'meier@meiermail.de',
                                   'firstname' => 'Max',
                                   'lastname' => 'Meier',
                                   'salutation' => 'mr',
                                   'billing' => {
                                       'firstname' => 'Max',
                                       'lastname' => 'Meier',
                                       'salutation' => 'mr',
                                       'street' => 'Mustergasse 55',
                                       'city' => 'Musterstadt',
                                       'zipcode' => '12345',
                                       'country' => 2
                                   }}.to_json)
  end
end

Shopware=SwApiWrapper.new
pp Shopware.post_customer

```

Alles das die api mir dann zurück gibt ist

```
{"success"=>false, "message"=>"Resource not found"}

```

Kann mir hier jemand aufs Pferd helfen? Ich verstehe einfach nicht welche Formatierung Shopware hier von mir möchte, ich habe das Beispiel aus der Doku ja schon fast identisch übernommen. Vielen Dank schon jetzt.

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [12. März 2019 um 19:33 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/2 "2019-03-12T19:33:07Z")

</div>

/costumers

zu

/customers

---

<div class="post-metadata">

**Author:** ![rtuzth](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rtuzth](https://forum.shopware.com/u/rtuzth)\
**Post date:** [14. März 2019 um 08:29 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/3 "2019-03-14T08:29:51Z")

</div>

Du meine Güte, das ist mir jetzt aber peinlich. Vielen Dank! Auf jeden Fall ein Schritt in die richtige Richtung, jetzt bekommme ich einen 405 zurück  
&nbsp;

```
{"success"=>false,
 "code"=>405,
 "message"=>"This resource has no support for batch operations."}

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![rtuzth](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rtuzth](https://forum.shopware.com/u/rtuzth)\
**Post date:** [14. März 2019 um 08:32 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/4 "2019-03-14T08:32:33Z")

</div>

…weil es natürlich ein post statt einem put sein muss. Falls jemand genauso blind ist wie ich. Sorry fürs spammen, es ist mir erst aufgefallen als der Beitrag schon veröffentlicht war.

---

<div class="post-metadata">

**Author:** ![wsd](https://avatars.discourse-cdn.com/v4/letter/w/e47774/32.png) [@wsd](https://forum.shopware.com/u/wsd)\
**Post date:** [21. Mai 2019 um 15:48 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/5 "2019-05-21T15:48:40Z")

</div>

Hallo,

Dein Problem ist zwar schon gelöst, aber wenn Du mit Ruby an einem Client arbeitest, kannst Du mir vielleicht bei einem angrenzenden Problem helfen…

Ich versuche ebenfalls mit HTTParty einen Kunden anzulegen, habe aber Probleme mit der Authentifizierung für POST. Mit basic\_auth kann ich mit GET meine Kundendaten abrufen und mit DELETE den Shop-Cache löschen, aber jeder Versuch mit POST auf die API zuzugreifen endet mit einem 403.

Selbst wenn ich mit CURL direkt zugreife:

403 Forbidden
# Forbidden

You don’t have permission to access /shopware.php  
on this server.

Wie muss ich denn bei POST User und Passwort übertragen? GET geht immer, bei POST bin ich mit allen mir bekannten Methoden gescheitert ☹

---

<div class="post-metadata">

**Author:** ![rtuzth](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@rtuzth](https://forum.shopware.com/u/rtuzth)\
**Post date:** [24. Mai 2019 um 14:21 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/6 "2019-05-24T14:21:13Z")

</div>

Hi,  
ich habe bis jetzt nur mit digest\_auth gearbeitet, das hat für mich problemlos funktioniert. Sorry!

---

<div class="post-metadata">

**Author:** ![ahmadsaad](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@ahmadsaad](https://forum.shopware.com/u/ahmadsaad)\
**Post date:** [26. Mai 2019 um 17:25 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/7 "2019-05-26T17:25:34Z")

</div>

> [@rtuzth schrieb:](https://forum.shopware.com/profile/31065/rtuzth "rtuzth")
> 
> Du meine Güte, das ist mir jetzt aber peinlich. Vielen Dank! Auf jeden Fall ein Schritt in die richtige Richtung, jetzt bekommme ich einen 405 zurück  
> &nbsp;
> 
> {„success“=\>false,  
> „code“=\>405,  
> „message“=\>„This resource has no support for batch operations.“}
> 
> &nbsp;

Hallo @rtuzth,

wie stett in das message , das&nbsp;Probleme , dass du hast ein Array mit mehrer Customers schicken.

bitte überprüfen Sie Ihre Request Bady noch einmal.

und könnten Sie bitte das Json String hier eintragen , damit sehe ich was passiert genau hier.

VG,

Ahmad

---

<div class="post-metadata">

**Author:** ![wsd](https://avatars.discourse-cdn.com/v4/letter/w/e47774/32.png) [@wsd](https://forum.shopware.com/u/wsd)\
**Post date:** [29. Mai 2019 um 10:07 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/8 "2019-05-29T10:07:48Z")

</div>

Hallo rtuzth,

Danke für den Tipp, aber leider bringt das keine Besserung:

Ich habe jetzt auf digest\_auth umgestellt, GET funktioniert ohne Probleme, POST bringt nach wie vor einen 403 “You don’t have permission to access shopware.php on this server”.

Hast du vielleicht noch’n Tipp?

---

<div class="post-metadata">

**Author:** ![MarcusMay](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@MarcusMay](https://forum.shopware.com/u/MarcusMay)\
**Post date:** [14. Juni 2019 um 13:46 UTC](https://forum.shopware.com/t/kunde-uber-api-erstellen/58520/9 "2019-06-14T13:46:10Z")

</div>

Ich klinke mich auch mal in diesen Thread mit ein. Ich bin auch gerade dabei, unsere WaWi an Shopware anzubinden. Beim Update eines Kunden bekomme ich ebenfalls die Meldung “This resource has no support for batch operations.”. Ich bin mir aber ziemlich sicher, dass ich beim PUT-Request KEIN Array an Shopware sende.&nbsp;

Beispiel (hier wird nur der Nachname und die Email-Adresse des Kunden geändert). Die folgenden Daten stammen aus Fiddler (um sicherzugehen, dass ich hier tatsächlich die transferierten Daten poste und nicht irgendwelche Variableninhalte aus meinem Code):

GET /api/customers/42&nbsp;

```
{	"data": {
		"number": "",
		"id": 42,
		"changed": "2019-06-14T14:41:08+0200",
		"paymentId": 5,
		"groupKey": "w",
		"shopId": 1,
		"priceGroupId": null,
		"encoderName": "bcrypt",
		"hashPassword": "$2y$10$GNH/0CYl1xsZokCwjal2OuZnsdidNPIm8Rm.HFjjVOoIht..2zY56",
		"active": true,
		"email": "test@test.de",
		"firstLogin": "2019-05-07T00:00:00+0200",
		"lastLogin": "2019-06-14T14:41:51+0200",
		"accountMode": 0,
		"confirmationKey": "",
		"sessionId": "gbdtra6upoiu5v5ir1pe5skp48",
		"newsletter": 0,
		"validation": "",
		"affiliate": 0,
		"paymentPreset": 0,
		"languageId": "1",
		"referer": "",
		"internalComment": "",
		"failedLogins": 0,
		"lockedUntil": null,
		"salutation": "mr",
		"title": null,
		"firstname": "Max",
		"lastname": "Mustermann",
		"birthday": null,
		"doubleOptinRegister": false,
		"doubleOptinEmailSentDate": null,
		"doubleOptinConfirmDate": null,
		"attribute": {
			"id": 37,
			"customerId": 42,
			"alphaAllowedPaymentMethods": null
		},
		"defaultBillingAddress": {
			"id": 40,
			"company": null,
			"department": null,
			"salutation": "mr",
			"firstname": "Max",
			"title": null,
			"lastname": "Mustermann",
			"street": "Teststr. 1",
			"zipcode": "12345",
			"city": "Testingen",
			"phone": null,
			"vatId": null,
			"additionalAddressLine1": null,
			"additionalAddressLine2": null,
			"countryId": 2,
			"stateId": null,
			"attribute": {
				"id": 13,
				"customerAddressId": 40,
				"text1": null,
				"text2": null,
				"text3": null,
				"text4": null,
				"text5": null,
				"text6": null
			},
			"country": {
				"id": 2,
				"name": "Deutschland",
				"iso": "DE",
				"isoName": "GERMANY",
				"position": 1,
				"description": "",
				"taxFree": 0,
				"taxFreeUstId": 0,
				"taxFreeUstIdChecked": 0,
				"active": true,
				"iso3": "DEU",
				"displayStateInRegistration": false,
				"forceStateInRegistration": false,
				"allowShipping": true,
				"areaId": 3
			},
			"state": null
		},
		"paymentData": [],
		"defaultShippingAddress": {
			"id": 40,
			"company": null,
			"department": null,
			"salutation": "mr",
			"firstname": "Max",
			"title": null,
			"lastname": "Mustermann",
			"street": "Teststr. 1",
			"zipcode": "12345",
			"city": "Testingen",
			"phone": null,
			"vatId": null,
			"additionalAddressLine1": null,
			"additionalAddressLine2": null,
			"countryId": 2,
			"stateId": null,
			"attribute": {
				"id": 13,
				"customerAddressId": 40,
				"text1": null,
				"text2": null,
				"text3": null,
				"text4": null,
				"text5": null,
				"text6": null
			},
			"country": {
				"id": 2,
				"name": "Deutschland",
				"iso": "DE",
				"isoName": "GERMANY",
				"position": 1,
				"description": "",
				"taxFree": 0,
				"taxFreeUstId": 0,
				"taxFreeUstIdChecked": 0,
				"active": true,
				"iso3": "DEU",
				"displayStateInRegistration": false,
				"forceStateInRegistration": false,
				"allowShipping": true,
				"areaId": 3
			},
			"state": null
		}
	},
	"success": true
}

```

PUT /api/customers/&nbsp;

```
{
  "id": 42,
  "paymentId": 5,
  "groupKey": "w",
  "shopId": 1,
  "encoderName": "bcrypt",
  "hashPassword": "$2y$10$GNH/0CYl1xsZokCwjal2OuZnsdidNPIm8Rm.HFjjVOoIht..2zY56",
  "active": true,
  "email": "abc@xyz.de",
  "firstLogin": "2019-05-07T00:00:00+0200",
  "lastLogin": "2019-06-14T14:41:51+0200",
  "accountMode": 0,
  "confirmationKey": "",
  "sessionId": "gbdtra6upoiu5v5ir1pe5skp48",
  "newsletter": 0,
  "validation": "",
  "affiliate": 0,
  "paymentPreset": 0,
  "languageId": "1",
  "referer": "",
  "internalComment": "",
  "failedLogins": 0,
  "salutation": "mr",
  "firstname": "Max",
  "number": "",
  "lastname": "Meier",
  "attribute": {
    "id": 37,
    "customerId": 42
  },
  "defaultBillingAddress": {
    "id": 40,
    "salutation": "mr",
    "firstname": "Max",
    "lastname": "Mustermann",
    "street": "Teststr. 1",
    "zipcode": "12345",
    "city": "Testingen",
    "countryId": 2,
    "attribute": {
      "id": 13,
      "customerAddressId": 40,
      "text1": null,
      "text2": null,
      "text3": null,
      "text4": null,
      "text5": null,
      "text6": null
    },
    "country": {
      "id": 2,
      "name": "Deutschland",
      "iso": "DE",
      "isoName": "GERMANY",
      "position": 1,
      "description": "",
      "taxFree": 0,
      "taxFreeUstId": 0,
      "taxFreeUstIdChecked": 0,
      "active": true,
      "iso3": "DEU",
      "displayStateInRegistration": false,
      "forceStateInRegistration": false,
      "areaId": 3
    }
  },
  "paymentData": [],
  "defaultShippingAddress": {
    "id": 40,
    "salutation": "mr",
    "firstname": "Max",
    "lastname": "Mustermann",
    "street": "Teststr. 1",
    "zipcode": "12345",
    "city": "Testingen",
    "countryId": 2,
    "attribute": {
      "id": 13,
      "customerAddressId": 40,
      "text1": null,
      "text2": null,
      "text3": null,
      "text4": null,
      "text5": null,
      "text6": null
    },
    "country": {
      "id": 2,
      "name": "Deutschland",
      "iso": "DE",
      "isoName": "GERMANY",
      "position": 1,
      "description": "",
      "taxFree": 0,
      "taxFreeUstId": 0,
      "taxFreeUstIdChecked": 0,
      "active": true,
      "iso3": "DEU",
      "displayStateInRegistration": false,
      "forceStateInRegistration": false,
      "areaId": 3
    }
  }
}

```

&nbsp;

Viele Grüße

Marcus
