D
D
danis_20142017-01-28 18:56:13
Python
danis_2014, 2017-01-28 18:56:13

How to send Request Payload via Requests library?

It is necessary to automate the receipt of referral links from the site . When receiving a link manually, the browser sends a post request with the Payload part: aa63ce0604df4b4e879cd794ffa6fdd9
I am also trying to make such a request:

def getUrl(login, password, link):
    with requests.Session() as session:
        data = dict(username=login, password=password, remember=1, check_ip=0)
        url = session.get('https://epn.bz')
        login = session.post('https://epn.bz/ru/auth/login', data=data, cookies=url.cookies)
        cabinet = session.get('https://epn.bz/ru/cabinet/', cookies=login.cookies)
        payload = {'all_banners': False,
                   'attract_to_cashback': False,
                   'cookie_time': "30days",
                   'desc': 'programme',
                   'expiration_time': '',
                   'format': '1',
                   'image': '',
                   'isAllow': 0,
                   'lang': 'ru',
                   'link': link,
                   'no_affiliate_direct': True,
                   'offer_type': 'ali',
                   'rejectChange': False,
                   'selected_banners': [],
                   'size': None}
        create = session.post('https://epn.bz/ru/creative/create', data=payload, cookies=cabinet.cookies)
        print(create.text)

But in the response we get: {"success":0,"message":"not_aliexpress"}
However, the link to the Ali site is transmitted exactly the same as when sending the request manually through the browser.
Am I passing the Payload part correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artyom Innokentiev, 2017-01-29
@danis_2014

Read and look in the browser Request Headers . Most likely you need to fake HTTP_REFERER.

D
danis_2014, 2017-01-29
@danis_2014

The problem turned out to be in the transmitted headers and in the json format of the payload part, everything is resolved

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question