# Admin components requests

**URL:** https://forum.shopware.com/t/admin-components-requests/70737
**Category:** Programmierung
**Created:** [6. November 2020 um 18:42 UTC](https://forum.shopware.com/t/admin-components-requests/70737 "2020-11-06T18:42:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ebess](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@ebess](https://forum.shopware.com/u/ebess)
#### Post date: [6. November 2020 um 18:42 UTC](https://forum.shopware.com/t/admin-components-requests/70737/1 "2020-11-06T18:42:21Z")

</div>

Hallo Leute,

ich versuche über eine Adminkomponente für v6.3.3.1 ein Request zu machen, aber anscheinend hat sch die Api verändert. Vielleicht kann mir einer helfen, wie ich das Problem am besten löse.

&nbsp;

```
{
  template,
  inject: [
    'pluginService',
  ],
  methods: {
    foo() {
      const headers = this.pluginService.getBasicHeaders();
      return this.pluginService.httpClient.post('/foo/bar', {headers}).then((response) => {
        const res = Shopware.Classes.ApiService.handleResponse(response);
        // do stuff
      });
    },
  },
}

```

Kriege dann diese Fehlermeldung:  
&nbsp;

> {„errors“:[{„status“:„400“,„code“:„FRAMEWORK\_\_WRITE\_MALFORMED\_INPUT“,„title“:„Bad Request“,„detail“:„Expected data to be array.“,„meta“:{„parameters“:}}]}

Hoffe ihr könnt mir weiterhelfen! Danke sehr!

---

<div class="post-metadata">

### Author: ![Moorleiche](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Moorleiche](https://forum.shopware.com/u/Moorleiche)
#### Post date: [7. November 2020 um 01:05 UTC](https://forum.shopware.com/t/admin-components-requests/70737/2 "2020-11-07T01:05:41Z")

</div>

1. Die post methode benötigt 3 Parameter
2. Headers ist im falschen Format, es muss { headers: headers } sein…

oder bau dir einen eigenen service

```
import ApiService from 'src/core/service/api.service';

class FoundationApiService extends ApiService {
    constructor(httpClient, loginService, apiEndpoint = '') {
        super(httpClient, loginService, apiEndpoint);
    }

    get(path) {
        const apiRoute = this.getApiBasePath() + path;
        return this.httpClient.get(
            apiRoute,
            {
                headers: this.getBasicHeaders()
            }
        ).then((response) => {
            return ApiService.handleResponse(response);
        });
    }

    post(path, data) {
        const apiRoute = this.getApiBasePath() + path;
        return this.httpClient.post(
            apiRoute,
            data,
            {
                headers: this.getBasicHeaders()
            }
        ).then((response) => {
            return ApiService.handleResponse(response);
        });
    }
}

export default FoundationApiService;

```

&nbsp;

---

<div class="post-metadata">

### Author: ![lav](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@lav](https://forum.shopware.com/u/lav)
#### Post date: [7. November 2020 um 06:52 UTC](https://forum.shopware.com/t/admin-components-requests/70737/3 "2020-11-07T06:52:57Z")

</div>

**Hello If you using Get method then call api like&nbsp;**

careerdelete function name&nbsp;

&nbsp; careerdelete: function (item) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const headers = this.pluginService.getBasicHeaders();  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return this.pluginService.httpClient  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .get(’/shipcloud/deletelabel/’, {headers})  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .then((response) =\> {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; location.reload(true);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).catch(error =\> {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });  
&nbsp; &nbsp; &nbsp; &nbsp; },

&nbsp;

If you using POST method then

Data you can pass using **const** &nbsp;

&nbsp;const data = {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; orderID: this.order.orderNumber,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; emailID:this.order.orderCustomer.email,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;}

return this.pluginService.httpClient  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .post(’/swag/returnlabel’,data,{headers})  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .then((response) =\> {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (response.data.type == ‚error‘)  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this.createNotificationError({  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title: response.data.type,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message: response.data.message  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.createNotificationError({  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title: response.data.type,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message: response.data.message  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });  
&nbsp; &nbsp; &nbsp;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).catch(error =\> {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });

&nbsp;
