0

I've been able to pull data for a specific list, but unable to filter it down to one item, where the Field called "File Name" equals drugdealers. Any assistance would be appreciated.

<script type="text/javascript">
$.ajax({
url: "https://gumdropsgc.sharepoint.com/sites/Training/_api/web/lists/getbytitle('Modules')/items(1)/?$filter=File_x0020_Name Eq drugdealers",
type: "GET",
headers: {"Accept": "application/json;odata=verbose"},
cache:false,                
success: function(data){
console.log(data);
var items = [];
$(data.d.results).each(function(){
items.push('<ul id="' + 'listUL' + '">' + 
'<li id="' + 'listLI' + '">' + 
this.Title  +
'</li>' + 
'</ul>');
});
items.push("</div>");
$("#listResult").html(items.join(''))}
});
</script>

<div id="listResult"></div>
1

drop the (1) in the url. You are querying just item number 1. If you want to limit to 1 item use top.

url: "https://gumdropsgc.sharepoint.com/sites/Training/_api/web/lists/getbytitle('Modules')/items?$filter=File_x0020_Name Eq 'FDAAgents'&$top=1"

Watch your results though. returning 1 item comes back differently than returning a set of items containing 1 item. (I use DHC chrome app to make sure I am getting back what I expect to be getting before developing on it. Lots of folks including MS support use fiddler)

  • That did it, big thanks for all the help. Let me know if I need to make a separate post for my next question. I'd be happy to do so. I was able to test and pull data. Now, how in the world do I format the date returns and spaces. Currently, it just joins all the data into one long string of all my columns that meet the one query for page1. How do I format it to something like this: Title: Regions Module: FDAAgents Comments: This course is for you. – Bitspider Jan 14 '15 at 5:07
  • Throwing that into another separate question provides more community benefit if you don't mind. – ghangas Jan 14 '15 at 16:15
  • google fp142385 – ghangas Jan 14 '15 at 16:21
0

Change the URL as below

url: "https://gumdropsgc.sharepoint.com/sites/Training/_api/web/lists/getbytitle('Modules')/items(1)/?$filter=File_x0020_Name Eq 'drugdealers'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.