MYOBCommunity
Partner Zone
|
|
Partner Zone

encoding Odata URL

This thread is now closed to new comments.
Some of the links provided in this thread may no longer be available or relevant.
If you have a question please start a new post.
4 REPLIES
API Evangelist KeranM
265 Posts
API Evangelist
Australia
KeranM
API Evangelist

265Posts

80Kudos

53Solutions

Accepted Solution Solved Solution

Re: encoding Odata URL

Hey

the \ before the $ escapes it and stops PHP looking for a $filter variable (eg $thirtyDaysAgo is a var)

Oh and DateOccurred doesn't exist in CustomerPayment (http://developer.myob.com/api/accountright/v2/sale/customerpayment/) so change that to Date Smiley Happy
Keran McKenzie
Futurist in residence @MYOB

Are you a developer? Check out http://developer.myob.com
Looking for an Add-on? Check out http://myob.com/addons/

Twitter: @myobapi | @keranm
Partner Derek_Cyfe
3 Posts
Partner
Derek_Cyfe
Partner

3Posts

0Kudos

0Solutions

Re: encoding Odata URL

Almost forgot, when I make a request to this URL this is the error I get: {
"Errors": [
{
"Name": "OData Query Error",
"Message": "The property 'DateOccurred' is not an expected property.",
"AdditionalDetails": "",
"ErrorCode": 0,
"Severity": null
}
],
"Information": "Warning, error messages have not been finalised in this release and may change"
}

Partner Derek_Cyfe
3 Posts
Partner
Derek_Cyfe
Partner

3Posts

0Kudos

0Solutions

Re: encoding Odata URL

Hi Keran,

 

Thanks for the quick reply! The current URL I'm using is 

 

/Sale/CustomerPayment/?$filter=DateOccurred%20ge%20datetime%272014-02-01%27%20and%20DateOccurred%20le%20datetime%272014-02-28%27

 

I noticed that your URL has 'Bill?\$filter'. What does the '\' do?

I also noticed that your URL kept the single quotations marks, but the PHP rawurlencode encodes them as %27. What is considered proper? 

API Evangelist KeranM
265 Posts
API Evangelist
Australia
KeranM
API Evangelist

265Posts

80Kudos

53Solutions

Re: encoding Odata URL

Hi there Derek

Yes with filter strings you need to ensure the spaces are encoded as %20 - I think urlencode does that (sorry it's been a while since I did it).

Here's an example of a url with $filter from one of my test files:

/Purchase/Bill?\$filter=Terms/DueDate%20le%20datetime'$thirtyDaysAgo'%20and%20Status%20eq%20'Open'
Keran McKenzie
Futurist in residence @MYOB

Are you a developer? Check out http://developer.myob.com
Looking for an Add-on? Check out http://myob.com/addons/

Twitter: @myobapi | @keranm
Highlighted
Partner Derek_Cyfe
3 Posts
Partner
Derek_Cyfe
Partner

3Posts

0Kudos

0Solutions

Solved: Go to Solution

encoding Odata URL

Hello,

 

I am currently having issues correctly building out my URL due to Odata requirements. 

say I have the query parameter $filter, what part of '$filter=Active eq true' should be encoded? Just the part after the equals sign? Also, I am currently using PHP's rawurlencode, but should I be using urlencode instead?

 

Any help would be greatly appreciated!

 

Derek Olson

Didn't find your answer here?
Try using advanced search to find a post more easily Advanced Search
or
Get the conversation started and make a new post Start a Post