Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Call to Live Market Data API giving error as below

    Test
    0
    3
    29
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sanky last edited by

      @Moderator_2 @admin
      Hello Team ,
      I am trying to call Live Market data with the below payload , however it is giving me error as highlighted .
      Payload :
      payload = {
      "mode": "LTP",
      "exchangeTokens": {
      "NSE": [
      "3045", "881"
      ],
      "NFO": [
      "35078"
      ]
      }
      }
      headers = {
      'X-PrivateKey': '*******',
      'Accept': 'application/json',
      'X-SourceID': 'WEB',
      'X-ClientLocalIP': 'CLIENT_LOCAL_IP',
      'X-ClientPublicIP': 'CLIENT_PUBLIC_IP',
      'X-MACAddress': 'MAC_ADDRESS',
      'X-UserType': 'USER',
      'Authorization': 'twttoken is placed here ',
      'Accept': 'application/json',
      'X-SourceID': 'WEB',
      'Content-Type': 'application/json'
      }

      The Error ::
      chunk = f'{len(chunk):X}\r\n'.encode('ascii') + chunk
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      TypeError: can't concat str to bytes

      M 1 Reply Last reply Reply Quote 0
      • M
        Moderator_2 @Sanky last edited by

        Hi @Sanky

        Apologies for delayed response.
        We have verified the payload and header from our end. Live Market Data API is working fine for the same.
        Kindly verify on the code for "TypeError: can't concat str to bytes" with the below reference.
        https://www.askpython.com/python/type-error-cant-concat-bytes-to-str#:~:text=To fix the “can't,without raising a type error.
        If the issue has not resolved. Please share the code snippet consumed for us to analyze further.

        Thanks & Regards,
        SmartAPI team

        O 1 Reply Last reply Reply Quote 0
        • O
          omshri29 @Moderator_2 last edited by

          @Moderator_2

          does the payload needs to be json i have tried the same but received 400 bad request?
          Can u share a working example in python code?

          Thank you

          1 Reply Last reply Reply Quote 0
          • First post
            Last post