"The expression is not valid" when performing SharePoint Rest call - rest

I have a SharePoint site and when I call
SITE/_api/web/lists/
it gives me the data for all the lists no problem. The problem is once I start querying for a specific list (for example one called "Environments") by calling
SITE/_api/web/lists/getbytitle("Environments")/
it gives me the error
Microsoft.SharePoint.Client.InvalidClientQueryExceptionThe expression "web/lists/getbytitle(Environments)/items" is not valid.
Am I not building the URL right or is there something wrong with the site.

Use apostrophes (') instead of quotation marks around the title of your list.
If your list tile has apostrophes in its title, you need to escape those by replacing each apostrophe with %27%27.

Correct REST URL to get list items is :
http://site url/_api/web/lists/GetByTitle('Test')/items
You are missing single quotes around List name.
Check MSDN : https://msdn.microsoft.com/en-us/library/office/dn292552.aspx

Related

Using "is null" when retrieving prices doesn't work

I am trying to get the price items for performance block storage that are generic (not specific to a certain datacenter). I can see that these have the locationGroupId set to blank or null, but I can't seem to get the objectFilter to work with that, the query returns nothing. If I omit the locationGroupId filter I get a result that contain both location-specific and non-location specific prices.
GET /rest/v3.1/SoftLayer_Product_Package/759/getItemPrices.json?objectMask=mask[locationGroupId,id,categories,item]&objectFilter={"itemPrices":{"categories":{"categoryCode":{"operation":"performance_storage_space"}},"item":{"keyName":{"operation":"$=GBs"}},"locationGroupId":{"operation":"is null"}}}
I am guessing there is something wrong with the object filter, any ideas?
If I filter on locationGroupId 509 it works:
/rest/v3.1/SoftLayer_Product_Package/759/getItemPrices.json?objectMask=mask[locationGroupId,id,categories,item]&objectFilter={"itemPrices":{"categories":{"categoryCode":{"operation":"performance_storage_space"}},"item":{"keyName":{"operation":"$=GBs"}},"locationGroupId":{"operation":509}}}
The reason it the first query didn't work while the second did was that I used the command "curl -sg" to do the request. While that eliminates the need to escape the {}[] characters - it also turns off escaping other characters correctly in the URL - like the space in "is null". Changing that to "is%20null" solves the issue.
I am posting this as the answer as I find it likely for others to encounter this problem.

Query string parsing as number when it should be a string

I am trying to send a search input to a REST service. In some cases the form input is a long string of numbers (example: 1234567890000000000123456789). I am getting 500 error, and it looks like something is trying the convert the string to a number. The data type for the source database is a string.
Is there something that can be done in building the query string that will force the input to be interpreted as a string?
The service is an implementation of ArcGIS server.
More information on this issue per request.
To test, I have been using a client form provided with the service installation (see illustration below).
I have attempted to add single and double quotes, plus wildcard characters in the form entry. The form submission does not error, but no results are found. If I shorten the number("1234"), or add some alpha numeric characters ("1234A"), the form submission does not error.
The problem surfaced after a recent upgrade to 10.1. I have looked for information that would tie this to a known problem, but not found anything yet.
In terms of forcing the input to be interpreted as a string, you enclose the input in single quotes (e.g., '1234567890000000000123456789'). Though if you are querying a field of type string then you need to enclose all search strings in single quotes, and in that case none of your queries should be working. So it's a little hard to tell from the information you've provided what exactly you are doing and what might be going wrong. Can you provide more detail and/or code? Are you formatting a where clause that you are using in a Query object via one of Esri's client side API's (such as the JavaScript API)? In that case, for fields of data type string you definitely need to enclose the search text in single quotes. For example if the field you are querying were called 'FIELD', this is how you'd format the where clause:
FIELD = '1234'
or
FIELD Like '1234%'
for a wildcard search. If you are trying to enter query criteria directly into the Query form of a published ArcGIS Server service/layer, then there too you need to enclose the search in single quotes, as in the above examples.
According to an Esri help technician, this is known bug.

Keyword search in facebook graph api

I am searching the facebook status which contains the specific keywords as follows.
https://graph.facebook.com/search?q=test&date_format=U&limit=60
&access_token={MY_ACCESS_TOKEN}
the above query returns the result correctly,
But when i search the keyword contains the space (ex: graph api). It doesn't returns the status which contains the keyword "graph api".
It returns the results of the keyword search graph and api seperately.
Is there any possible way to search the keywords which contains the space?
Update:
Methods which have been tried by me:
https://graph.facebook.com/search?q=facebook+search&date_format=U&
limit=60&access_token={{MY_ACCESS_TOKEN}}
https://graph.facebook.com/search?q=facebook%20search&date_format=U&
limit=60&access_token={{MY_ACCESS_TOKEN}}
https://graph.facebook.com/search?q=facebook%20Bsearch&date_format=U&
limit=60&access_token={{MY_ACCESS_TOKEN}}
https://graph.facebook.com/search?q="facebook search"&date_format=U&
limit=60& access_token={{MY_ACCESS_TOKEN}}
the above all gave the same result.
What you might want to try is taking your query and performing a URL encode on it. You can try these two options -
https://graph.facebook.com/search?q=graph+api&date_format=U&limit=60
&access_token={MY_ACCESS_TOKEN}
https://graph.facebook.com/search?q=graph%20api&date_format=U&limit=60
&access_token={MY_ACCESS_TOKEN}
These two options attempt to encode the space character in the query first with a + character, and then with %20. I'm fairly sure that one (or both) of these options will provide the results you are looking for.

What is [ ] in google chrome developer console?

While testing code in the google chrome developer console, i get
[]
and sometimes i get "".
The later shows up,when i think there not such strings available with the current selector combinations.But i still couldn't figure out the meaning of the former [] square brakets.
Please help.
With the information that you've given, all we can do is make assumptions. However, when you're logging things to the console, [] is an empty array, whereas "" is an empty string.
[] are returned whenever you jquery returns empty object. i.e. you selector expression cant locate what you are trying to search.
whereas "" is just simple string
i looked into your given site..
when i tried :
$('.four columns alpha') i get object[] (which means there jquery is returning empty object)
but when you write correct expression like :
$('.four.columns') you will get array of Div's which can be used like object.
Hope i'm able to make you understand. if any doubts do write.
And $('.four columns alpha') this is not the right way to select div's with more than one css class right way is to do something like below:
$('.four.columns.alpha')

How to use keywords include ampersand(&) in Facebook Search API

I want to use some keywords that include special characters like & in Facebook search api. I tried the query below but I cannot get useful results. Is there any chance for this usage in search api? How should I build my search query?
My example queries and keywords are "H&M", "marks & spencer",
http://graph.facebook.com/search?type=post&limit=25&q="H&M"
http://graph.facebook.com/search?type=post&limit=25&q="marks & spencer"
My team worked on this forever, ended up finding this as a solution that provides relevant results for a query with an ampersand, such as 'H&M'.
%26amp%3b
This is the hex equivilent to &
So your example link would be
http://graph.facebook.com/search?type=post&limit=25&q="H%26amp%3bM"
We found the solution thanks to Creative Jar
You want %26 which is the URL encode for ampersand so
http://graph.facebook.com/search?type=post&limit=25&q="H%26M" http://graph.facebook.com/search?type=post&limit=25&q="marks %26 spencer"
Depending on your language, it may have a URL encoding function or you can just use string replacement.
It seems, that all of solutions suggested here are not working any more.
Searching for q=H%26%bM returns empty data set. The same for q=H%26M.
It must have changed recently, in last 2 months.
If you try to search for postings about H&M on Facebook site (type H&M in search, then "Show me more results" on the bottom of list and then public posts on menu on the left side) the list is empty.
The only query that returns any results is q=H&M but it is not helpful, as the results are irrelevant for that query.