Home > Software engineering >  Microsoft Graph API - PHP Curl single quotes
Microsoft Graph API - PHP Curl single quotes

Time:11-29

I'm trying to query events from a group calendar using a cURL request in PHP and I need to get a specific date range (i.e. this month only). The problem is that anytime I use a filter with single quotes, I get a "Bad Request" error. The same string however works fine in the Microsoft Graph Explorer.

https://graph.microsoft.com/v1.0/groups/12345/events?filter=start/dateTime ge '2022-10-01T12:30:00' and end/dateTime lt '2022-11-01T12:30:00'

I have no issues reaching any other endpoint as long as I'm not using a filter with single quotes. I've tried using curl_escape as well as manually encoding the string and I keep getting "Bad Request".

Any ideas?

Thanks

CodePudding user response:

look up url encoding

urlencode("start/dateTime ge '2022-10-01T12:30:00' and end/dateTime lt '2022-11-01T12:30:00'");

returns

start/dateTime ge '2022-10-01T12:30:00' and end/dateTime lt '2022-11-01T12:30:00'
  • Related