Whats the sharepoint rest endpoint to get a web by its id - rest

I have a webid and a listid in a sharepoint page. I'm trying to construct a rest url to get to the list.
I cant figure out the url to get the web given the WebID.
I tried
https://xxxx.sharepoint.com/_api/web/webs(guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d')
https://xxxx.sharepoint.com/_api/web/webs('33213c5c-30e5-468c-87f7-52b48a7b6a3d')
https://xxxx.sharepoint.com/_api/web/webs/GetById('33213c5c-30e5-468c-87f7-52b48a7b6a3d')
How do I get at the web with that id? I need to get a list in the web.
I was thinking it was going to be as simple as
https://xxxx.sharepoint.com/_api/web/webs(guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d')/lists(guid'the-list-id'), but I cant get at the web!
++++++++++++++++ mReply to vadim ++++++++++++++++++++++++
Thanks Vadim,
You got me pointed in the right direction
This url will get me to the web:
https://xxx.sharepoint.com/_api/web/webs?$filter=iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d'
This url will get me all items in all lists in all webs
https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items
This url will get me all items in all lists in a specified web:
https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items&$filter=iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d'
But how doe I get all items in a specified list in a specified web?
This doesnt work:
https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items&$filter=((iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d' ) and (Lists/Id eq guid'd38444af-dd7f-404b-9e75-b1f8c6cdee7d' ))
Its a valid Web id and a valid list id, but sharepoint complains :m:message xml:lang="en-US">Field or property "Id" does not exist.
any ideas?

Web resource could be retrieved using $filter query option as demonstrated below:
/_api/web/webs?$filter=ID eq guid'c01e1b4a-e671-431d-97aa-4b02a57803c7'
In order to retrieve the corresponding List resource by id you could consider the following approach:
Perform request to get Web Url by its Id:
/_api/web/webs?$select=ServerRelativeUrl&$filter=ID eq
guid'c01e1b4a-e671-431d-97aa-4b02a57803c7'
Get List by id: {web url}/_api/Web/Lists(guid'b778bbec-dd69-4a6c-9437-c73972c36292')
where {web url} is web site url found in the first request

Related

How to get Sharepoint user by Title using REST?

I'm trying to search for a given user on a Sharepoint site using "lastname, firstname". I was able to use the following url to get the total list of site users as a large XML document:
https://thissite.com/sites/thatsite/_api/web/siteusers/
However, I haven’t been able to figure out how to search by Title. When I use the following url:
https://thissite.com/sites/thatsite/_api/web/siteusers/getbytitle(“lastname,%20firstname”)
I get this error:
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>
-1, Microsoft.SharePoint.Client.InvalidClientQueryException
</m:code>
<m:message xml:lang="en-US">
The expression "web/siteusers/getbytitle("lastname, firstname")" is not valid.
</m:message>
</m:error>
When I use the following url to get the same user's data:
https://thissite.com/sites/thatsite/_api/web/siteusers/getbyid(41)
Then I successfully get XML returned with that user's data.
I guess I could just parse the list obtained from /siteusers and load it into a searchable data object, but I was hoping for something more direct.
UserCollection resource does not expose getbytitle method, that's the reason why you get this exception.
In order filter user by title you could utilize $filter query option as demonstrated below:
https://contoso.sharepoint.com/_api/web/siteusers?$filter=Title eq '<Title>'

Getting post lists from facebook pages

I'm trying fetch list of post from given set of facebook pages using restfb(java)
List fbPages = Arrays.asList("178697151159/posts", "538560813021153/posts");
JsonObject fetchObjectsSubResults = client.fetchObjects(fbPages, JsonObject.class, Parameter.with("fields","shares,created_time"),Parameter.with("limit", 5));
But I'm getting a runtime error from facebook api as following.. IS there any body that can help me out to resolve this or is this impossible (
Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: (#803) Some of the aliases you requested do not exist: 178697151159/posts?,538560813021153/posts? (code 803, subcode null)
at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1278)
at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1195)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1136)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:1058)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:1020)
at com.restfb.DefaultFacebookClient.fetchObjects(DefaultFacebookClient.java:476)
at main.main(main.java:75)
I suggest using 1 call per page. SO it should look like:
Connection<Post> postConnection = client.fetchConnection(pageId+ "/posts", Post.class, Parameter.with("fields","shares,created_time"), Parameter.with("limit","5"));
Depending on your use case, you can run over the postConnection with a for loop to get all posts or take the data from the first page of the result set with postConnection.getData().
In both cases you can eventually work with a Post type and access the fields your are interested in. The other fields are left null.
BTW working with multiple ids in a single call or request these ids one after another makes no difference to the Facebook calls. The amount that is internally calculated is the same; in your case 2.

Node-RED and REST APIs with resource id's

I'm trying to use Node-RED to develop a REST based API. For example, a GET would be:
http://myurl.com/widgets/"widget-id"
where "widget-id" would be 123. I can get this to work using query strings. However, I can't seem to figure out what to put on the http input node to allow a resource id to get passed. Am I missing something obvious? Any ideas on what I need to do?
The other answer is nearly right, it just needs tweaking for Node-RED
If you set the URL in the HTTP Input node to /widget/:id
you can access the widget id in a function node linked to the HTTP Input node as follows:
var id = msg.req.params.id;
if you get all widgets:
router.get('/widgets/', function(data){});
if only one item(for example - 123):
router.get('/widgets/:id(\\d+)', function(data){});
in you're browser or if you using POSTMAN enter http url: http://youredomain.com/widgets/or http://youredomain.com/widgets/123

cq.util.eval function retuning null object when the request coming from Web server

I have below function in the search.jsp. I'm using an object abc to get the search and promote account details dynamically.
var abc= CQ.Util.eval(spPath+'/jcr:content.json');
Here consider sPath is search and promote directory (ex: /etc/cloudservoices/search-promote/abc-search-promote)
If I print the value of abc in publish instance (http://publish:4503/en-US/home.html) then it's returning an object whereas it's returning null if I access it through the web server (http://test:80/en-US/home.html).
Can you kindly suggest what might possibly be wrong?

Get the first product id in a magento system via soap api (2)?

Question: Is there a way (api call) to get the first product id in a magento install via the soap api.
I'm attempting to download all the products from a magento system and insert them into a different database (I do the conversion myself so that's not a bother) What is hard to understand though is how do I get a list of the product id's without getting all of them, if all I know is that the site is up.
Here's the info I have.
soap end point
soap username
soap apikey (aka password)
Here's what I don't know.
the id of any of the products
the date any of the products were created on or last edited.
For my initial load, I have to do a where product id in, because I expect 20 to 40k product lists won't come back in one soap call.
So I call
where id in (1 -> 100) Nope
where id in (101-> 200) Nope..
Now as you can imagine that code smells something fierce. It works, but I have to think there is a better way..
To expand my question: Is there a better way?
I can post the XML that I'm sending if that helps. The language I'm using to create the soap(xml) is vim, so I don't have code I can paste.
Try This
$client = new SoapClient('http://localhost/magento8/index.php/api/soap/?wsdl');
$session = $client->login('soap username', 'soap apikey');
$filters=array('entity_id'=>array(array('lt'=>'1','gt'=>'100')));//get fist 100 result
$result = $client->call($session, 'catalog_product.list',array($filters));
var_dump($result);
for more attributes check this
http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento