Trying to convert from python request to chilkat2.HttpRequest :
import requests
data = {"username": "user","password": "pass","remember": "on"}
sign_in_url = 'https://www.tradingview.com/accounts/signin/'
signin_headers = {'Referer': 'https://www.tradingview.com'}
response = requests.post(url=sign_in_url, data=data, headers=signin_headers)
token = response.json()['user']['auth_token']
P.S. Cause no right username and password - will return status_code:200 b'{"error":"Invalid username or password","code":"invalid_credentials"}'
I have this:
http = chilkat2.Http()
req = chilkat2.HttpRequest()
req.AddParam("username","user")
req.AddParam("password","pass")
req.AddParam("remember","on")
req.Path = '/accounts/signin/'
req.HttpVerb = "POST"
http.FollowRedirects = True
http.SendCookies = True
http.SaveCookies = True
http.CookieDir = "memory"
resp = http.SynchronousRequest('www.tradingview.com',443,True,req)
print(http.LastErrorText)
But response - statusCode: 403 Forbidden What am I doing wrong?
See the tradingview.com API documentation: https://www.tradingview.com/rest-api-spec/#section/Authentication
You can see that an application/x-www-form-urlencoded POST is required.
It's easy to do with Chilkat. See this documentation showing how to send common HTTP request types: https://www.chilkatsoft.com/http_tutorial.asp
You'll want to send a request like this: https://www.chilkatsoft.com/http_post_url_encoded.asp