Skip to Content
0
Jul 30, 2020 at 05:02 PM

Logon Token Syntax for RESTFul API Using Python in Jupyter Notebook

219 Views

I have been working with Python to access the BO repository (Semantic layer, Webi, etc.) info using the RESTFul API. I am new to python and also new to using APIs, but have been using BO itself for a while. I have been able to send successful POST and GET commands using a Chrome plug-in called Talend API tester, which is really cool. Now i'm trying to convert these tests to a python script inside a Jupyter notebook that will eventually perform all sorts of cool magic tricks. When i try to apply the successful commands from the in-browser API tester to a Jupyter notebook using Python, i am getting errors related to media format. I'm guessing it's something simple.

My next step will be to use the results of the Logon Key GET command to send the subsequent POST command with the Logon but for now I just want to become more comfortable with sending basic commands to the BO repository by manually using the Logon Token.

This works fine:

Part 1
Command:

import requests
response = requests.get("http://servername:8080/biprws/logon/long")
print(response.content)

Response:b' http://www.sap.com/rws/bip"> name="password" type="string"> secEnterprise '

Part 2

When i run this though i get a 415 status code:

Command:

header = 'Content-Type: application/xml'
body = ' http://www.sap.com/rws/bip"> name="password" type="string">MyPassword secEnterprise my.username '
addy = 'http://servername:8080/biprws/logon/long'

response = requests.post(addy,header,body)

print(response)

Response: