Answer the question
In order to leave comments, you need to log in
What is the correct way to send an encrypted POST request in Python?
The response to the POST request is 'Seems you are providing invalid input data. Provide data in valid format.'
AES/ECB/PKCS5Padding encryption algorithm. I've been suffering for several days now, I've read and tried a lot. User_token is issued freely after registration. Instructions from the site:
Request URL : https://bondevalue.com/app/bondDetailsHistoryData
Request Method : POST
Request Content-Type : application/x-www-form-urlencoded
Request Parameter :
requestData
= "{\"data\":{\"userToken\ ":\"[userToken]\"},\"bondISINId\":\"[isinId]"\"" "\"fromDate\":\"[from
date]\" "}"
[Note: The requestData will be encrypted by a encryption algorithm]
Example:
Before Encryption Data : {
"data":{"userToken":"slabnt1l540udrh0"},"bondISINcode":"XS1401197253" "fromDate":""}ylwciqc9e2E4kwYCRRsAvUcQlQ7cn23QMO22i+9FH/3n4peo+9dm7XMnNSx3E45WZiNEUsepGQN HED2kzqKporz5bQTOzP8i/tD57OCE7kUr5EIeaqk8OKzmHu8KeQAM
Note: This particular API requires the bond 's ISIN Id and the from date to view the history data for
that particular ISIN ID.
import requests
import json
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import base64
client_token = b'1234123412341234'
requestData = b'{\"data\":{\"userToken\":\"[1234123412341234]\"},\"bondISINId\":\"[XS1401197253]\", \"fromDate\":\"[2016-12-07]\"}'
cipher1 = AES.new(client_token, AES.MODE_ECB)
requestEncrypted = base64.b64encode(cipher1.encrypt(pad(requestData, 16))).decode('utf-8')
url = 'https://bondevalue.com/app/bondDetailsHistoryData'
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = {'requestData': requestEncrypted}
answer = requests.post(url=url, data=requestEncrypted, headers=headers)
response = answer.json()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question