This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3235MODASF: Hotsless Mode AT Commands

Part Number: CC3235MODASF

Hello,

Our company bought the CC3235MODASF evaluation kit. 

I've been tasked to use the kit as hostless mode and via HTTPClient commands to send a GET request to a server with BASIC authentication.

There's enough documentation to start the kit and connect to a pre-defined Wi-Fi network, but not enough to use the HTTP Client.

Here's my flow :

1. Connect to a network (pre-defined SSID and password)

2. Create an HTTP client (HTTPCreate)

3. Connect HTTP to a host (using the HTTPConnect AT Command) 

4.Set HTTP header (using the HTTPSetHeader AT Command) (the data is parsed as simple string)

5. Send the request 

I receive 401 error code, which is weird as I checked the authentication using Postman and it worked.

So my thought is the issue isn't with encoding the <user:pass>.

Also, I've tried sending a request to other hosts and I've succeeded to get a response.

P.S: I use Python with pySerial to send the AT Commands and base64 encoding the authentication.

  • Hi Eduard,

    Without knowing more about the setup, I don't know why the HTTP server would be returning an unauthorized response. You can try printing out the HTTP request header and compare it to your working setup.

    This E2E thread discusses how to debug a 401 error in more detail. As a suggested in this thread, you can add source/ti/net/http/httpclient.c directly to your IDE project, and add a UART_PRINT inside sprsend() after the SlNetSock_send() to print cli->validBufStart to the terminal.

    Best regards,

    Sarah

  • I found out I could use httpbin.org to send a GET request and the server will reply back with the header that it received so I can check the header params.

    so I configured the header user-agent with my data and sent the request. The server replied with the same user-agent, so setting the header works for me.

    This is part of my script in python:

        # Defining Request Header
        send_at_cmd(f'AT+HttpSetHeader={http_client_index},req_host,persistent,0,{len(api_host)},{api_host}')
        send_at_cmd(f'AT+HttpSetHeader={http_client_index},req_auth,persistent,0,{len(auth_b64)},"{auth_b64}"') # params containing spaces must be enclosed with ""
        send_at_cmd(f'AT+HttpSetHeader={http_client_index},req_user_agent,persistent,0,{len(user_agent)},{user_agent}')
    
        response = send_at_cmd(f"AT+HttpConnect={http_client_index},https://{api_host},,,,")
    
        if response['ok']:
            # Sending Request
            response = send_at_cmd(f"AT+HttpSendReq={http_client_index},get,{req_uri},,,,")
            
            # Reading Response
            if response and response['ok']:
                if int(response['values'][0]) == 200:
                    print("")
                    send_at_cmd(f"AT+HttpReadResBody={http_client_index},0,1024")
                elif int(response['values'][0]) >= 500:
                    print("")
                    print(" -------------------  Server Error  -------------------  ")
                elif int(response['values'][0]) >= 400:
                    print("")
                    print(" -------------------  Client Error  -------------------  ")

    send_at_cmd is a simple function I made to send the string over UART ,wait for a response and read its values.

    Python version 3.8.1 , pyserial version 3.5.

    Note: The server im trying to access is using HTTPS.

  • Hi Eduard,

    Does the server have an error log that can tell you why the connection is refused?

    Best regards,

    Sarah

  • Found out the issue i had!

    for future reference:

    Apparently my flow wasn't correct. I changed my flow to set the headers before I make an HTTP connection and I do not set the host header field (used to get 3019 error when I did set it up) as I guess it automatically updates when the connection is set.