Python sharepoint connection - unable to access - python

I am trying to access my sharepoint site using python. The sharepoint URL looks something like this: https://companyname.sharepoint.com/teams/mysitename. Following tutorials online on creating sites in sharepoint, somehow my site URL becomes https://companyname.sharepoint.com/teams/mysitename instead of https://companyname.sharepoint.com/sites/mysitename and this causes an issue trying to create the sharepoint-python connection.
I am referring to this document https://shareplum.readthedocs.io/en/latest/tutorial.html. The methods used in the document do not work when the domain name uses 'teams' instead of 'sites'. Would appreciate any help. Thanks!

Related

Sharepoint API how to read file havin only sharing link to it

I'm using python office365 library to access sharepoint documents. I don't know how to access file via API that have been shared with me by sharing link. I need to get this file content and if possible metadata (last modify date). Could anyone help?
The user that I'm using have no access to this sharepoint folder other than a sharing link to a single file.
I tried many variations of normal file access API, bot by hand and by office365 library. I couldnt find a way to access a file when I have only sharing link to it.
My sharing link looks like that:
https://[redacted].sharepoint.com/:x:/s/[redacted]/dir1/dir2/ESd0HkNNSbJMhQFavQsr9-4BNHC2rHSWsnbs3zRdjtZsC3g so there is not really a filename here and I cannot read via API content of any folder per se because I have an error Attempted to perform an unathorized operation.. Authentication goes fine (when i mistake password I get different error).
According to my research and testing, you can use the following Rest API to read file (get file content):
https://xxxx.sharepoint.com/sites/xxx/_api/web/GetFolderByServerRelativeUrl('/sites/xxx/Library_Name/Folder Name')/Files('Document.docx')/$value
If you want to get last modify date, you can use the following Rest API to get the Modified field:
https://xxxx.sharepoint.com/sites/xxx/_api/web/lists/getbytitle('test_library')/Items?$select=Modified

Export sharepoint list data to excel using python

I have sharepoint url where i can open and export that sharepoint list into excel. I want to automate that using python. i have tried many suggestions from online. but none of those are working.
i have tried below code to connect sharepoint
import requests
url= 'my sharepoint file path here'
r=requests.get(url,verify=False) #no username or password required
i am expecting the code should export sharepoint list data to new excel file.
I haven’t done this myself with code, but I believe it should work similar to what’s been done in SharePoint 2013: Export To Excel Using REST API
What they do there is actually using a link to a query that Excel can understand with parameters as the list id and view id. Since they use code within the browser it recognizes the content type (.iqy file) as something that should be opened in Excel. Don’t know how that would be when dont in Python though.
Another thing: Unless you have anonymous access turned on in your site, you need to authenticate the request to SharePoint.

What permission(s) do I need to read the names of the users who posted to a Facebook page?

I want to write a Python script that reads the names of the Facebook users who wrote a message on my Facebook Page.
I'm using the facebook-sdk Python library. The lines
graph = facebook.GraphAPI(page_access_token)
profile = graph.get_object(profile_id)
posts = graph.get_connections(profile['id'], 'feed')
print(posts['data'][0]['message'])
print(posts['data'][0]['from']['name'])
work fine when I use a short-lived access token retrieved by just copying it from the Graph API explorer.
But when I generate a never-expiring page access token (read here), there is an error in the last line where the Python script wants to retrieve the name. (KeyError: 'from')
So how do i set the right permissions? The access token has user_about_me, user_posts, read_page_mailboxes, manage_pages, publish_pages, public_profile permissions, but it still doesn't work. Maybe I did something wrong setting up the app I created to retrieve a new access token?
Or maybe this isn't a permissions issue after all? (See my previous question.)
You need to specify the fields you want to retrieve manually if you're using v2.4 or higher. Unfortunately this is not documented in the project you're using:
posts = graph.get_connections(profile['id'], 'feed', 'fields=id,message,from')
should work I guess according to https://github.com/pythonforfacebook/facebook-sdk/blob/master/facebook/init.py#L117

CiteULike API 'forbidden'

I am trying to query counts of bookmarks for research papers in CiteULike. I am using the "http://www.citeulike.org/api/posts/for/doi/" URL in order to put in a request (using urllib2 library for Python) for an XML document which contains information on the bookmarks for a given DOI (unique identifier for papers). However I keep getting a HTTP 403 Error: Forbbiden.
Does anyone know why I am getting this error? I've tried putting the URL with the DOI in the browser and that returns the XML just fine, so the problem seems related to my automated requests.
Thanks,
Nathanael
You should read http://wiki.citeulike.org/index.php/Importing_and_Exporting#Scripting_CiteULike
If you access CiteULike via an automated process, you MUST provide a
means to identify yourself via the User-Agent string. Please use
"<username>/<email> <application>" e.g., "fred/fred#wilma.com
myscraper/1.0". Any scripting of the site without a means to identify
you may result in a block.

I am getting same version name for WSS and MOSS 2007?

I am getting same version name for WSS and MOSS 2007?
response = urllib2.urlopen(url)
print response.info().getheader('MicrosoftSharePointTeamServices')
I am using the above python code to get the verion of the sharepoint verion using the site URL.
WSS:MicrosoftSharePointTeamServices: 12.0.0.4518
MOSS:MicrosoftSharePointTeamServices: 12.0.0.4518
SP2010:MicrosoftSharePointTeamServices: 14.0.0.4762
So i am confused now because for MOSS and WSS it return the same version id.Why its happening how to resolve it?
Is there any v\way to
The version is exactly the same for both. MOSS is nothing more than a couple of extra modules on top of WSS.
Have a look at this post about how to differentiate between MOSS and WSS from inside SharePoint code.
Not sure if this will help you as you want to look remotely. You may want to consider adding a simple web service to your SharePoint instance. Alternatively try requesting a MOSS only web page and see if that exists.

Categories

Resources