Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 400, Creating new class #62

Closed
sefaYavuz opened this issue Jun 6, 2016 · 5 comments
Closed

Error 400, Creating new class #62

sefaYavuz opened this issue Jun 6, 2016 · 5 comments

Comments

@sefaYavuz
Copy link

sefaYavuz commented Jun 6, 2016

I get the following error when i try to create the class SalesItemPrice and use the get() function:

exception 'Picqer\Financials\Exact\ApiException' with message 'Error 400: Please add a $select or a $top=1 statement to the query string.'

This is the code for the class SalesItemPrice:

<?php namespace Picqer\Financials\Exact;

/**
 * Class SalesItemPrice
 *
 * @package Picqer\Financials\Exact
 * @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=LogisticsSalesItemPrices
 *
 * @property Guid $ID Primary key
 * @property Guid $Account ID of the customer
 * @property String $AccountName Name of the customer account
 * @property DateTime $Created Creation date
 * @property Guid $Creator User ID of creator
 * @property String $CreatorFullName Name of creator
 * @property String $Currency The currency of the price
 * @property String $DefaultItemUnit The default unit of the item
 * @property String $DefaultItemUnitDescription The description of the default item unit
 * @property Int32 $Division Division code
 * @property DateTime $EndDate Together with StartDate this determines if the item is active
 * @property Guid $Item Item ID
 * @property String $ItemCode Code of Item
 * @property String $ItemDescription Description of Item
 * @property DateTime $Modified Last modified date
 * @property Guid $Modifier User ID of modifier
 * @property String $ModifierFullName Name of modifier
 * @property Double $NumberOfItemsPerUnit This is the multiplication factor when going from default item unit to the unit of this price.For example if the default item unit is 'gram' and the price unit is 'kilogram' then the value of this property is 1000.
 * @property Double $Price The actual price of this sales item
 * @property Double $Quantity Minimum quantity to which the price is applicable
 * @property DateTime $StartDate Together with StartDate this determines if the item is active
 * @property String $Unit The unit code of the price
 * @property String $UnitDescription Description of the price unit
 */
class SalesItemPrice extends Model
{

    use Query\Findable;
    use Persistance\Storable;

    protected $fillable = [
        'ID',
        'Account',
        'AccountName',
        'Created',
        'Creator',
        'CreatorFullName',
        'Currency',
        'DefaultItemUnit',
        'DefaultItemUnitDescription',
        'Division',
        'EndDate',
        'Item',
        'ItemCode',
        'ItemDescription',
        'Modified',
        'Modifier',
        'ModifierFullName',
        'NumberOfItemsPerUnit',
        'Price',
        'Quantity',
        'StartDate',
        'Unit',
        'UnitDescription'
    ];

    protected $url = 'logistics/SalesItemPrices';

}
@stephangroen
Copy link
Member

What does your code look like?

@remkobrenters
Copy link
Collaborator

This is not an error in the code. In specific instances, sadly not documented in the API documentation of Exact this is a requirement. Probably to prevent overflooding requests. What you have to do when encountering this error is adding a select or top. The select is used to provide a list of fields you want to extract, the $top=1 limits the results to one item.

Examples:
$test = new GeneralJournalEntry($connection);
dd($test->filter('', '', 'EntryID, FinancialYear'));

Returning only the EntryID and FinancialYear.

The $top=1 is added like this:
$test = new GeneralJournalEntry($connection);
dd($test->filter('', '', '', ['$top'=> 1]));

@stephangroen
Copy link
Member

Thanks @remkobrenters, added your response to the readme :)

@remkobrenters
Copy link
Collaborator

You might want to slightly rewrite the examples as they are quit short and not conclusive :) but cool! Took me a while to figure this out myself last week. Almost added a pull for a slightly improved ->get() that allowed adding the $top=1 with a boolean or something.

@stephangroen
Copy link
Member

stephangroen commented Jun 7, 2016

Will add that to my todo list :) Planning on reviewing the entire readme soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants