system
January 24, 2023, 10:20am
1
Migrated from Redmine #1002 | Author: Mitun Talapatra
Status: Closed | Priority: High, I’m very impatient | Created: 2023-01-24
Hi There,
According to the REST API Documentation, I am trying to get all booking data. for authentification, I have tried following:
url = “https://user-api-v2.simplybook.me/admin/auth ”
headers = {‘Content-Type’: ‘application/json’}
data = {
“company”: “holmesplacedeutschland”,
“login”: “Mitun.Talapatra@holmesplace.de ”,
“password”: “XXXXX*”
}
response = requests.post(url, headers=headers, data=json.dumps(data))
response.json()
Result:
{‘token’: ‘xxxx’,
‘company’: ‘holmesplacedeutschland’,
‘login’: ‘Mitun.Talapatra@holmesplace.de’,
‘refresh_token’: ‘xxxx’,
‘domain’: ‘simplybook.me ’,
‘require2fa’: False,
‘allowed2fa_providers’: ,
‘auth_session_id’: ‘’,
‘id’: None}
To get booking list:
headers_booking = {
‘Content-Type’: ‘application/json’,
‘X-Company-Login’: ‘holmesplacedeutschland’,
‘X-User-Token’: response.json()[‘refresh_token’] ,
}
booking_list = requests.get(‘https://user-api-v2.simplybook.me/admin/bookings ’, headers=headers_booking)
booking_list.json()
Result:
{‘code’: 401, ‘message’: ‘Unauthorized’, ‘data’: , ‘message_data’: }
system
January 24, 2023, 10:23am
2
Dmytro Bondarev wrote:
Hi, please pass token instead of refresh_token.
'X-User-Token': response.json()['token'] ,
system
January 24, 2023, 10:26am
3
Mitun Talapatra wrote:
Dmytro Bondarev wrote:
Hi, please pass token instead of refresh_token.
[…]
Still same error:
{‘code’: 401, ‘message’: ‘Unauthorized’, ‘data’: , ‘message_data’: }
system
January 24, 2023, 10:27am
4
Dmytro Bondarev wrote:
Please provide full raw HTTP request, including headers.
system
January 24, 2023, 10:29am
5
Mitun Talapatra wrote:
Dmytro Bondarev wrote:
Please provide full raw HTTP request, including headers.
headers_booking = {
‘Content-Type’: ‘application/json’,
‘X-Company-Login’: ‘holmesplacedeutschland’,
‘X-User-Token’: response.json()[‘token’]
}
booking_list = requests.get(‘https://user-api-v2.simplybook.me/admin/bookings ’, headers=headers_booking)
booking_list.json()
system
January 24, 2023, 10:30am
6
Dmytro Bondarev wrote:
Sorry but we need full raw HTTP request.
You can have some mistakes in your code.
system
January 24, 2023, 10:36am
7
Mitun Talapatra wrote:
Please find it in attachment.
Thanks
system
January 24, 2023, 10:38am
8
Dmytro Bondarev wrote:
Can’t see it. Please just paste HTTP request here.
system
January 24, 2023, 10:42am
10
Mitun Talapatra wrote:
Here is the full code:
import requests
import json
import warnings
warnings.filterwarnings(“ignore”, category=FutureWarning)
url = “https://user-api-v2.simplybook.me/admin/auth ”
headers = {‘Content-Type’: ‘application/json’}
data = {
“company”: “holmesplacedeutschland”,
“login”: “Mitun.Talapatra@holmesplace.de ”,
“password”: “hp2022!Ta*”
}
response = requests.post(url, headers=headers, data=json.dumps(data))
headers_booking = {
‘Content-Type’: ‘application/json’,
‘X-Company-Login’: ‘holmesplacedeutschland’,
‘X-User-Token’: response.json()[‘token’]
}
booking_list = requests.get(‘https://user-api-v2.simplybook.me/admin/bookings ’, headers=headers_booking)
booking_list.json()
system
January 24, 2023, 10:44am
11
Redmine Admin wrote:
unfortunately we are unable to check your code, please provide raw http request which were send to our server
system
January 24, 2023, 10:46am
12
Mitun Talapatra wrote:
Redmine Admin wrote:
unfortunately we are unable to check your code, please provide raw http request which were send to our server
That’s all written in my notebook.
Can we have a short call please?
system
January 24, 2023, 10:51am
13
Mitun Talapatra wrote:
Does it work for you?
1st request:
Method: POST
URL: https://user-api-v2.simplybook.me/admin/auth
Headers:
Content-Type: application/json
Body:
{
“company”: “xxxx”,
“login”: “xxxx”,
“password”: “xxxx*”
}
And the second request
Method: GET
URL: https://user-api-v2.simplybook.me/admin/bookings
Headers:
Content-Type: application/json
X-Company-Login: xxxxx
X-User-Token: response.json()[‘token’]
Note that the response.json()[‘token’] in headers will be replaced by actual token value when the request is made.
system
January 24, 2023, 10:52am
14
Redmine Admin wrote:
we need actual headers sent to our API server, there is no way to see what will be replaced and will it be or not, maybe problem is because it was not replaced
system
January 24, 2023, 10:55am
15
Mitun Talapatra wrote:
Redmine Admin wrote:
we need actual headers sent to our API server, there is no way to see what will be replaced and will it be or not, maybe problem is because it was not replaced
this is exactly what I have followed as the documentation. do you need login and token info?
system
January 24, 2023, 11:00am
16
Mitun Talapatra wrote:
second request
Method: GET
URL: https://user-api-v2.simplybook.me/admin/bookings
Headers:
Content-Type: application/json
X-Company-Login: holmesplacedeutschland
X-User-Token: ‘002e3d4433d6fc86206b8e7fb0b8da6b5907d2da56a64e29bee6fd4b82417c36’
system
January 24, 2023, 11:02am
17
Dmytro Bondarev wrote:
Please remove quotas from X-User-Token header.
It must be
X-User-Token: 002e3d4433d6fc86206b8e7fb0b8da6b5907d2da56a64e29bee6fd4b82417c36
system
January 24, 2023, 11:03am
18
Dmytro Bondarev wrote:
Also you should set X-Token instead of X-User-Token.
system
January 24, 2023, 11:08am
19
Mitun Talapatra wrote:
But you have suggested to use X-User-Token earlier?
system
January 24, 2023, 11:10am
20
Dmytro Bondarev wrote:
For REST API it must be X-Token, please check documentation.