1

I am trying to use the exact online API, my web application can connect with the API and create Accounts, Items and all the other things.

But now, inside off my web application I need those Accounts and Items etcetera, I got it done to select all the Items and import those into my database, but I can't find the SalesPrice of an Item, only the 'CostPriceNew' and 'CostPriceStandard'!

After a while searching, I found out that there is another class called: ItemDetailsByID inside this class i found SalesPrice

At first i get an error: Fatal error: Uncaught TypeError: Argument 1 passed to Picqer\Financials\Exact\ItemDetailsByID::get() must be of the type array, string given

This is the code I used: `

//Retrieve items
$items = new \Picqer\Financials\Exact\Item($connection);
$result = $items->get();

foreach ($result as $item) {

    try {

        $ItemDetails = new \Picqer\Financials\Exact\ItemDetailsByID($connection);
        $result1 = $ItemDetails->get($item->ID);

        foreach ($result1 as $ItemDetail) {

            var_dump($ItemDetail);

        }
        
    } catch (\Exception $e) {

        echo json_encode(array(get_class($e) . ' : ' . $e->getMessage()));

    }

}

`

After reading the documentation from exact online i still don't managed to use this class.. now I am getting this error: ["Picqer\\Financials\\Exact\\ApiException : Error 400: Bad Request - Error in query syntax."]

After the first error I changed my code $result1 = $ItemDetails->get($item->ID);

into

$result1 = $ItemDetails->get(["eq guid" => "'$item->ID'"]);

I have tried multiple array keys like: 'eq guid', 'Edm.Guid', 'guid', 'id' but I stil get the error.

I hope that someone can help me or pointing me into the right direction.

Xxx red
  • 45
  • 1
  • 2
  • 11
  • ps, documentation can be found here: https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=ReadLogisticsItemDetailsByID – Xxx red Oct 14 '20 at 09:39
  • What is the actual URL requested that raises the http 400? – Guido Leenders Oct 14 '20 at 09:58
  • @guido read in the documentation; Function URI /api/v1/{division}/read/logistics/ItemDetailsByID?itemId={Edm.Guid} GET Example usage /api/v1/{division}/read/logistics/ItemDetailsByID?itemId=guid'00000000-0000-0000-0000-000000000000'&$select=Code – Xxx red Oct 14 '20 at 10:39
  • And what is the actual URL sent to Exact? – Guido Leenders Oct 14 '20 at 14:24
  • @GuidoLeenders i tried this, i don't know if this is what you mean!, inside the get() function i placed this code: `var_dump($this->url, $params);` and as result I get `string(48) "read/logistics/ItemDetailsByID?itemId={Edm.Guid}" array(1) { ["Edm.Guid"]=> string(38) "'8afc6734-ae20-4ab2-a44e-403ed41dc9c0'" }` – Xxx red Oct 14 '20 at 22:48
  • Is there someone who can help me please? i am stuck for a couple of days, and i can't find anything on google about this question :( – Xxx red Oct 15 '20 at 20:01

2 Answers2

1

You dont want to list all item prices, so instead of using get, you should use find. Since you only get one result, after that you can directly use the returned object:

$ItemDetails = new \Picqer\Financials\Exact\ItemDetailsByID($connection);
$result1 = $ItemDetails->find($item->ID);
var_dump($result1->SalesPrice);
0

Your question is not very clear, I try to give you a general suggestion before you add more info.

log the http protocol and compare with the doc, if you do not have a client log, you can send your request to httpbin.org(be careful with your password and other personal piracy using third party service), just like https://httpbin.org/get?itemId=guid'00000000-0000-0000-0000-000000000000'&$select=Code,SalesCurrency,SalesPrice.

It will print request info, this can help to debug

{
    "args": {
        "$select": "Code,SalesCurrency,SalesPrice",
        "itemId": "guid'00000000-0000-0000-0000-000000000000'"
    },
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate, br",
        "Cache-Control": "no-cache",
        "Host": "httpbin.org",
        "User-Agent": "PostmanRuntime/7.26.5",
    },
    "origin": "a.b.c.d",
    "url": "https://httpbin.org/get?itemId=guid'00000000-0000-0000-0000-000000000000'&$select=Code,SalesCurrency,SalesPrice"
}
Hieast
  • 87
  • 5