# Kann jemand bei der API Abfrage helfen?

**URL:** <https://forum.shopware.com/t/kann-jemand-bei-der-api-abfrage-helfen/69104>\
**Category:** Shopware Playground - API first Sandbox\
**Created:** [22. August 2020 um 07:42 UTC](https://forum.shopware.com/t/kann-jemand-bei-der-api-abfrage-helfen/69104 "2020-08-22T07:42:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danke](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@Danke](https://forum.shopware.com/u/Danke)\
**Post date:** [22. August 2020 um 07:42 UTC](https://forum.shopware.com/t/kann-jemand-bei-der-api-abfrage-helfen/69104/1 "2020-08-22T07:42:48Z")

</div>

Den Code den ich habe gibt nur alle Produkte aus, jedoch bekomme ich es nicht hin die Filter anzuweden:&nbsp;

In dem Postman kann ich filter anweden, aber Postman hat keinen guzzle integriert wie shopware.&nbsp;

Gerne würde ich 1,2 beispiele für funktierende GET und POST operationen hinbekommen.&nbsp;

Danke im Voraus.

```
 'https://www.plintenburg.com',
          'timeout' => 2.0,
          'headers' => ['Content-Type' => 'application/json'],'verify' => false,]);

 $clientId = "SWIAEHBRZWRUBTDBCNJ2SVLNTW";
 $clientSecret = "dzFNMEZXWUxpZFBucnRaS0g5cHJRSVFvNVUxNkZzc2YzR0pPNHM";

$body1 = json_encode([
            'client_id' => $clientId,
            'client_secret' => $clientSecret,
	    'grant_type' => 'client_credentials',
	    'scopes' => 'write',
    ]);

$response = $client->post(
	    '/api/oauth/token',
	    [
		'Content-Type' => 'application/json',
		'body' => $body1
	    ]
	);
$token = json_decode($response->getBody()->getContents(), true);
//Das ist die TokenAcces ausgebe!!
//print_r($token);

//my first attempt at using the body variable. Without success
$inhlattest ='{
    "ids": [
        "11dc680240b04f469ccba354cbf0b967", 
        "1901dc5e888f4b1ea4168c2c5f005540",
        "1f54875c658f464f95c198b9137391c4"
    ],
    "includes": {
        "product": ["id", "name"]
    }
}';

//my second attempt at using the body variable. Without success 
$inhalt ='{
    "filter": [
        { "type": "equals", "field": "productNumber", "value": "SWDEMO10002" }
    ],
    "includes": {
        "product": ["id", "name", "productNumber"]
    }
}';

echo $inhalt;

$token = json_decode((string) $response->getBody(), true)['access_token'];
    // mit access_token endpunkt auslesen
    if (isset($token)) {
	    $response = $client->request('POST','/api/v3/search/product', 
	[
	    	'headers' => [
			'User-agent'=> 'Mozilla/5.0',
			'Authorization' => 'Bearer ' . $token,
			'Content-Type' => 'application/json',
			'Content-Length' => '0',
			'Accept'=> '*/*',
		 	'Accept-Encoding'=> 'gzip',
			],
	],
	['body' => $inhalt]
);
//echo $response->getBody();
        // Ausgabe
        //return $response;
$body = $response->getBody();
$json_string = json_decode($body, JSON_PRETTY_PRINT);
header('Content-Type: application/json');
print_r($json_string);

    } else {
        return response()->json(['error' => request('error')]);
    }

?>

```

&nbsp;
