REST to filter on a FieldUrlValue

%3CLINGO-SUB%20id%3D%22lingo-sub-15821%22%20slang%3D%22en-US%22%3EREST%20to%20filter%20on%20a%20FieldUrlValue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15821%22%20slang%3D%22en-US%22%3E%3CP%3EHello%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20filter%20a%20list%20based%20on%20the%20Url%20value%20in%20a%20%3CSTRONG%3ESP.FieldUrlValue%20%3C%2FSTRONG%3Eusing%20REST.%20I%20tried%20to%20use%20the%20expand%20odata%20command%20but%20this%20did%20not%20work.%20If%20I%20select%20the%20field%20in%20the%20REST%20call%20it%20returns%20the%20whole%20value%20unlike%20a%20People%20field%20that%20requires%20expanding.%20Does%20this%20therefore%20mean%20it%20is%20not%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExample%20of%20what%20I%20have%20tried%20but%20to%20no%20avail%3C%2FP%3E%3CUL%3E%3CLI%3E%3CPRE%3Ehttps%3A%2F%2Fthesiteiamtestingagainst%2Fsites%2Ftest%2F_api%2Fweb%2Flists%2Fgetbytitle('Comments')%2Fitems%3F%24select%3DURL%26amp%3B%24filter%3DURL%20eq%20'http%3A%2F%2Fwww.bbc.co.uk'%3C%2FPRE%3E%3C%2FLI%3E%3CLI%3E%3CPRE%3Ehttps%3A%2F%2Fthesiteiamtestingagainst%2Fsites%2Ftest%2F_api%2Fweb%2Flists%2Fgetbytitle('Comments')%2Fitems%3F%24select%3DURL%26amp%3B%24filter%3DURL%2FUrl%20eq%20'http%3A%2F%2Fwww.bbc.co.uk'%24expand%3DURL%2FUrl%3C%2FPRE%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20I%20have%20tried%20both%20examples%20without%20the%20single%20quotes%20around%20%3CA%20href%3D%22http%3A%2F%2Fwww.bbc.co.uk%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.bbc.co.uk%3C%2FA%3E%20and%20with%20Double%20Quotes%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20attached%20an%20image%20of%20the%20field%20in%20a%20reponse%20form%20REST%20it%20I%20select%20all%20items%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBen%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16000%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20to%20filter%20on%20a%20FieldUrlValue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16000%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20your%20reply%20Paul%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20download%20both%20the%20U2U%20Caml%20builder%20and%20the%20RR%20Caml%20Builder%20form%20Codeplex%20(Latest%20version%20on%20Git)%20but%20while%20it%20shows%20me%20the%20Caml%20to%20use%20it%20does%20not%20give%20me%20the%20REST%20call.%20Within%20the%20Caml%20it%20specifies%20the%20type%20of%20URL.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhere%20you%20refering%20to%20Caml%20builder%20tool%20that%20also%20puts%20out%20the%20REST%20call%20for%20the%20query%3F%20If%20so%20where%26nbsp%3Bis%20this%20available%20to%20download%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-15999%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20to%20filter%20on%20a%20FieldUrlValue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15999%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20your%20reply%20Pieter%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20article%20relates%20to%20filtering%20via%20field%20called%20URL%20that%20is%20not%20a%20SP.FieldUrlValue%20type%20field%20but%20a%20text%20field.%20This%20would%20work%20but%20I%20need%20to%20filter%20on%20the%20SP.FieldUrlValue%20type%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-15998%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20to%20filter%20on%20a%20FieldUrlValue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15998%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20your%20reply%20Daniel%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%20this%20returns%20the%20following%20when%20I%20tried%20it.%3C%2FP%3E%3CPRE%3E%26lt%3Bm%3Aerror%20xmlns%3Am%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fado%2F2007%2F08%2Fdataservices%2Fmetadata%22%26gt%3B%0A%26lt%3Bm%3Acode%26gt%3B-1%2C%20Microsoft.SharePoint.SPException%26lt%3B%2Fm%3Acode%26gt%3B%0A%26lt%3Bm%3Amessage%20xml%3Alang%3D%22en-US%22%26gt%3B%0AThe%20field%20'URL'%20of%20type%20'URL'%20cannot%20be%20used%20in%20the%20query%20filter%20expression.%0A%26lt%3B%2Fm%3Amessage%26gt%3B%0A%26lt%3B%2Fm%3Aerror%26gt%3B%3C%2FPRE%3E%3CP%3EMaybe%20you%20cannot%20filter%20on%20the%20URL%20column%20type%20via%20REST%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-15950%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20to%20filter%20on%20a%20FieldUrlValue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15950%22%20slang%3D%22en-US%22%3E%3CP%3EWould%20suggest%20to%20get%20the%20caml%20query%20builder%20where%20it%20puts%20out%20the%20correct%20code%20and%20URL.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ekr%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPaul%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-15832%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20to%20filter%20on%20a%20FieldUrlValue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15832%22%20slang%3D%22en-US%22%3E%3CP%3Ehave%20a%20look%20at%20this%3A%20%3CA%20href%3D%22https%3A%2F%2Fsocial.technet.microsoft.com%2FForums%2Foffice%2Fen-US%2F79e3f7bc-924c-4974-b99c-3fa4cd5396b7%2Fhow-can-i-filter-by-an-url-field-with-rest-interface%3Fforum%3Dsharepointdevelopmentprevious%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsocial.technet.microsoft.com%2FForums%2Foffice%2Fen-US%2F79e3f7bc-924c-4974-b99c-3fa4cd5396b7%2Fhow-can-i-filter-by-an-url-field-with-rest-interface%3Fforum%3Dsharepointdevelopmentprevious%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-15831%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20to%20filter%20on%20a%20FieldUrlValue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15831%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%20couple%20of%20weeks%20ago%20I%20was%20doing%20similar%20things%20with%20a%20SPD%20site%20workflow%20for%20my%20client.%20I%20understand%20how%20fustrating%20the%20syntax%20is%20.%20%26nbsp%3BMake%20sure%20your%20response%20evelope%20is%20json%20with%20a%20request%20header%26nbsp%3B%3C%2FP%3E%3CPRE%3Eaccept%3Dapplication%2Fjson%3Bodata%3Dverbose%3C%2FPRE%3E%3CP%3EYou%20need%20to%20wrap%20brackets%20around%20your%20filter%20clause.%20-%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fthesiteiamtestingagainst%2Fsites%2Ftest%2F_api%2Fweb%2Flists%2Fgetbytitle('Comments')%2Fitems%3F%24filter%3D(URL%20eq%20'http%3A%2F%2Fwww.bbc.co.uk')%3C%2FPRE%3E%3CPRE%3Ehttps%3A%2F%2Fthesiteiamtestingagainst%2Fsites%2Ftest%2F_api%2Fweb%2Flists%2Fgetbytitle('Comments')%2Fitems%3Fslect%3DURL%26amp%3B%24filter%3D(URL%20eq%20'http%3A%2F%2Fwww.bbc.co.uk')%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20you%20need%20to%20get%20data%20out%20of%20your%20response%20evelope%20with%20a%20path%20similar%20to%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ed%2Fresults%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThereafter%20you%20can%20pick%20the%20values%20with%20the%20desired%20path%20-%20you%20will%20need%20to%20confirm%20this%20a%20tool%20like%20Postman.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20luck%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hello

 

I am trying to filter a list based on the Url value in a SP.FieldUrlValue using REST. I tried to use the expand odata command but this did not work. If I select the field in the REST call it returns the whole value unlike a People field that requires expanding. Does this therefore mean it is not possible?

 

Example of what I have tried but to no avail

  • https://thesiteiamtestingagainst/sites/test/_api/web/lists/getbytitle('Comments')/items?$select=URL&$filter=URL eq 'http://www.bbc.co.uk'
  • https://thesiteiamtestingagainst/sites/test/_api/web/lists/getbytitle('Comments')/items?$select=URL&$filter=URL/Url eq 'http://www.bbc.co.uk'$expand=URL/Url

NOTE: I have tried both examples without the single quotes around http://www.bbc.co.uk and with Double Quotes

 

I have attached an image of the field in a reponse form REST it I select all items

 

Thanks in advance

 

Ben

 

6 Replies
Highlighted

Hi

 

A couple of weeks ago I was doing similar things with a SPD site workflow for my client. I understand how fustrating the syntax is .  Make sure your response evelope is json with a request header 

accept=application/json;odata=verbose

You need to wrap brackets around your filter clause. -

  

https://thesiteiamtestingagainst/sites/test/_api/web/lists/getbytitle('Comments')/items?$filter=(URL eq 'http://www.bbc.co.uk')
https://thesiteiamtestingagainst/sites/test/_api/web/lists/getbytitle('Comments')/items?slect=URL&$filter=(URL eq 'http://www.bbc.co.uk')

 

I think you need to get data out of your response evelope with a path similar to 

 

d/results 

 

Thereafter you can pick the values with the desired path - you will need to confirm this a tool like Postman.

 

Good luck

 

 

Highlighted

Would suggest to get the caml query builder where it puts out the correct code and URL.

 

kr,

 

Paul

Highlighted

Thank you for your reply Daniel

 

Unfortunately this returns the following when I tried it.

<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-1, Microsoft.SharePoint.SPException</m:code>
<m:message xml:lang="en-US">
The field 'URL' of type 'URL' cannot be used in the query filter expression.
</m:message>
</m:error>

Maybe you cannot filter on the URL column type via REST?

Highlighted

Thank you for your reply Pieter

 

This article relates to filtering via field called URL that is not a SP.FieldUrlValue type field but a text field. This would work but I need to filter on the SP.FieldUrlValue type

Highlighted

Thank you for your reply Paul

 

I download both the U2U Caml builder and the RR Caml Builder form Codeplex (Latest version on Git) but while it shows me the Caml to use it does not give me the REST call. Within the Caml it specifies the type of URL.

 

Where you refering to Caml builder tool that also puts out the REST call for the query? If so where is this available to download?