Skip to content

httpx.HTTPStatusError: Redirect response '302 Moved Temporarily' #1952

Closed

Description

@daeeros

I have this code:

class Tracker:

    def __init__(self, login, password):

        self.login = login
        self.password = password
        self.api_url = 'https://tracking.russianpost.ru/rtm34?wsdl'

        httpx_client = httpx.AsyncClient(auth=(self.login, self.password))

        self.client = zeep.AsyncClient(
            self.api_url,
            transport=AsyncTransport(client=httpx_client),
            settings=zeep.Settings(strict=False, xml_huge_tree=True,)
        )

    async def get_history(self, barcode):

        return await self.client.service.getOperationHistory(
            OperationHistoryRequest={
                'Barcode': barcode,
                'MessageType': '0'
            },
            AuthorizationHeader={
                'login': self.login,
                'password': self.password,
            },
        )

But when it try to make auth, i getting error:

httpx.HTTPStatusError: Redirect response '302 Moved Temporarily' for url 'https://tracking.russianpost.ru/rtm34?wsdl'
Redirect location: 'https://tracking.russianpost.ru/tracking-web-static/rtm34_wsdl.xml'
For more information check: https://httpstatuses.com/302

How can if fix it?

Activity

  1. israelyago commented on Dec 14, 2021

    @israelyago

    Consider changing self.api_url = 'https://tracking.russianpost.ru/rtm34?wsdl' to https://tracking.russianpost.ru/tracking-web-static/rtm34_wsdl.xml

    I also was not able to cURL into the original url, possibly they are changing the API endpoints

    Since the status is 302, be careful: It means a _temporary _ redirection of a resource

  2. added
    question
    on Dec 14, 2021
  3. florimondmanca commented on Dec 14, 2021

    @florimondmanca
    Contributor

    Hi @daeeros, I'm going to move this as a discussion, since this seems like a usage question. Thanks.

  4. locked and limited conversation to collaborators on Dec 14, 2021
  5. converted this issue into a discussion #1969 on Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions