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

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.

Related

Python sharepoint connection - unable to access

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!

How to get request hostname from an HTTP-triggered, Python Azure Function request header?

I would greatly benefit from a list of all the available headers that App Service can forward to my (keyword PYTHON) Function. Or if someone knows how to "list-all", that would be awesome.
Through asking questions on SO, I see that the request IP addressed can be gleaned using:
req.headers.get("X-FORWARDED-FOR").
I need the Hostname that a request is coming from.
Looks like this is possible using C# Functions. But I either did it wrong using req.headers.Host or its not available for Python.
Is it possible using Python?
For this requirement, you just need to use req.headers.get("host"). I test it in my side, it works fine on azure portal.

Exception 400081 while downloading a view using TableauServerClient

I am using TableauServerClient (0.8) in a Python (3.7.1) script to download a view as .csv from Tableau server (2019.1.3 (20191.19.0417.1429) 64-bit Windows) onto my local machine. My code works for most of the views but for some views, I am getting following error:
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
400081: Bad Request
There was a problem querying the data for view 'xyz'
Has someone faced this issue in the past? Any thoughts?
I was facing a similar error & neither the documentation of Python API nor the REST API had any info about this issue. ( I couldn't even find the API response error code in either)
But after a long search, I stumbled upon a suggestion by the user 'gaoang2148' in this thread.
For me, the error was occurring because a few data sources in my workbook were missing connection credentials ( The credentials were missing after I published an update from Tableau Desktop). Once I embedded the credentials for each data source, the code was working fine again. i was able to pull & download data from tableau views via API.
When I have run into this, it’s been on newly published views. I believe it has to do with Tableau's behind the scenes managing of views and/or data in the repository. Sometimes it takes an hour or two for a new view that's been published to query properly from TSC. Manually navigating to the view in browser also might force the view to be processed, but that could've been coincidence when it's happened to me. It usually resolves itself within an hour.

Python requests call fails with HTTPS

I am running a Flask restful API behind an NGINX web server on AWS. I am hitting that with a python module from my Pi.
Everything worked fine when I was using HTTP to make calls to the api. But I just locked down my api so only HTTPS is possible. I changed the UIRL used by my python module but it now fails. The code is quite simple...here is an extract:
jsonpkg = {'subscriberID': self.api_login, 'token': self.api_token,
'content': speech_content}
headers = {'Content-Type': 'application/json'}
r = requests.post(self.api_apiurl, data=json.dumps(jsonpkg), headers=headers)
The values are being correct set by the class init section. And I am importing the requests module at the top. Error messages indicate it is using python 2.7. However when I monitor the API I can see its not even hitting the server. I can point a browser to the api and its working fine.
Am I to understand the requests module in python 2.7 does not support https?
Are there additional parameters I need to send for https?
Aha! With a little more digging into the request module docs I found the answer. If I use the following
r = requests.post(self.api_apiurl, data=json.dumps(jsonpkg), headers=headers, verify=False)
then it works. So the issue is with verifying the cert. I am not quite sure why the browser gets by without this...but perhaps it does the extra stuff automatically. So I either need to NOT verify the cert or have a local copy(?) that can be verified.
Final Update:
I finally worked out how to concatenate my site certificate with the chain certificate (and understand why). This site here was a great help. Also, once they are concatenated you will probably get a second error, which if you google it you will find is caused by the need for a carriage return after the first certificate and before the second (edit the resulting concatenated file with notepad). I then was able to return the post to using "verify=True" which made the warnings about no verification go away.

How to access YQL in Python (Django)?

Hey, I need a simple example for the following task:
Send a query to YQL and receive a response
I am accessing public data from python backend of my Django app.
If I just copy/paste an example from YQL, it says "Please provide valid credentials".
I guess, I need OAuth authorization to do it.
So I got an API key and a shared secret.
Now, what should I do with them?
Should I use python oauth library? This one?
http://oauth.googlecode.com/svn/code/python/oauth/
But what is the code? How I pass my secret/API key along with my yql query?
I guess, many Django programmers would love to know this.
I've just released python-yql also available on pypi. It can do public, two-legged oauth a.k.a signed requests and facilitate 3-legged outh too.
It's brand new so there may be some bugs whilst I work on improving the test coverage but should hopefully do what you need. See the source for some idea on how to use it.
Installing to try it is as follows:
sudo easy_install yql
Bug/Feature requests can be filed here: https://bugs.launchpad.net/python-yql
If you only are accessing public data you can just make a direct rest call from python.
>>> import urllib2
>>> result = urllib2.urlopen("http://query.yahooapis.com/v1/public/yql?q=select%20title%2Cabstract%20from%20search.web%20where%20query%3D%22paul%20tarjan%22&format=json").read()
>>> print result[:100]
{"query":{"count":"10","created":"2009-11-03T04:47:01Z","lang":"en-US","updated":"2009-11-03T04:47:0
And then you can parse the result with simplejson.
>>> import simplejson
>>> data = simplejson.loads(result)
>>> data['query']['results']['result'][0]['title']
u'<b>Paul</b> <b>Tarjan</b> - Silicon Valley, CA | Facebook'
Ok, I sort of resolved the problem.
In YQL console example for data/html the following url was presented as an example:
http://query.yahooapis.com/v1/yql?q=select+*+from+html+where+url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3Dyhoo%22+and%0A++++++xpath%3D%27%2F%2Fdiv%5B%40id%3D%22yfi_headlines%22%5D%2Fdiv%5B2%5D%2Ful%2Fli%2Fa%27
It does not work!
But if you insert "/public" after "v1/" than it magically starts working!
http://query.yahooapis.com/v1/public/yql?q=select+*+from+html+where+url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3Dyhoo%22+and%0A++++++xpath%3D%27%2F%2Fdiv%5B%40id%3D%22yfi_headlines%22%5D%2Fdiv%5B2%5D%2Ful%2Fli%2Fa%27
But the question of how to pass my API key (for v1/yql access) is still open. Any advice?

Categories

Resources