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.

CC3200: CC3200 - get method fails with 404 or 302 (while postman, or just using browser works)

Part Number: CC3200

Hi All

I am trying to implement a GET method with http_client_demo example, 

When testing with "httpbin.org" and "/get" it works fine and I get 200 status,

but with my own host I fail (404 or 302), although it does works with postman and my chrome browser, Why would a GET to an address request that works fine with Postman, will return status of 404 or 302 on my CC3200?

Thanks

  • Hi Amud,

    Just to be clear, the cc3200 is not having issues with connecting to the internet correct? For example, does it work if you were to ping google.com or 8.8.8.8?

  • Hi Sabeeh

    Thanks for responding, the cc3200 connects properly to the internet, I successfully got the correct response to a POST request from my server, and I did got a correct response to GET from another server.

    The problem is with getting a GET response from my server, I get 404, in another test I got 302

    Thanks. 

  • Hello Amud,

    Could you please post the source code that does these operations?

  • Hi Sabeeh,

    OK, This is my code for the "get" method test:

    #define APPLICATION_VERSION "1.4.0"
    #define APP_NAME            "HTTP Client"
    #define POST_REQUEST_URI 	"/post"
    //#define POST_REQUEST_URI    "/info.0.json"
    #define POST_REQUEST_URI    "/metadata/TheAdventuresOfTomSawyer_201303"
    #define POST_DATA           "{}"
    #define DELETE_REQUEST_URI 	"/delete"
    #define PUT_REQUEST_URI 	"/put"
    #define PUT_DATA            "PUT request."
    #define GET_REQUEST_URI     "/get"
    #define HOST_NAME           "httpbin.org" //"<host name
    
    #define HOST_NAME_GET "www.amudraa.com"
    #define GET_REQUEST_URI_TERMINAL     "/terminal"
    
    static int HTTPGetAmudMethod(HTTPCli_Handle httpClient)
    {
    
        long lRetVal = 0;
        HTTPCli_Field fields[4] = {
    
                                    {HTTPCli_FIELD_NAME_HOST, HOST_NAME_GET},
                                    {HTTPCli_FIELD_NAME_ACCEPT, "*/*"},
                                    {HTTPCli_FIELD_NAME_CONTENT_LENGTH, "0"},
                                    {NULL, NULL}
                                };
        bool        moreFlags;
    
    
        /* Set request header fields to be send for HTTP request. */
        HTTPCli_setRequestFields(httpClient, fields);
    
        /* Send GET method request. */
        /* Here we are setting moreFlags = 0 as there are no more header fields need to send
           at later stage. Please refer HTTP Library API documentaion @ HTTPCli_sendRequest
           for more information.
        */
        moreFlags = 0;
        lRetVal = HTTPCli_sendRequest(httpClient, HTTPCli_METHOD_GET, GET_REQUEST_URI_TERMINAL, moreFlags);
        if(lRetVal < 0)
        {
            UART_PRINT("Failed to send HTTP GET request.\n\r");
            return lRetVal;
        }
    
    
        lRetVal = readResponse(httpClient);
    
        return lRetVal;
    }
    
    //*****************************************************************************
    //
    //! \brief HTTP GET Demonstration
    //!
    //! \param[in]  httpClient - Pointer to http client
    //!
    //! \return 0 on success else error code on failure
    //!
    //*****************************************************************************
    static int HTTPGetMethod(HTTPCli_Handle httpClient)
    {
      
        long lRetVal = 0;
        HTTPCli_Field fields[4] = {
                                    {HTTPCli_FIELD_NAME_HOST, HOST_NAME},
                                    {HTTPCli_FIELD_NAME_ACCEPT, "*/*"},
                                    {HTTPCli_FIELD_NAME_CONTENT_LENGTH, "0"},
                                    {NULL, NULL}
                                };
        bool        moreFlags;
        
        
        /* Set request header fields to be send for HTTP request. */
        HTTPCli_setRequestFields(httpClient, fields);
    
        /* Send GET method request. */
        /* Here we are setting moreFlags = 0 as there are no more header fields need to send
           at later stage. Please refer HTTP Library API documentaion @ HTTPCli_sendRequest
           for more information.
        */
        moreFlags = 0;
        lRetVal = HTTPCli_sendRequest(httpClient, HTTPCli_METHOD_GET, GET_REQUEST_URI, moreFlags);
        if(lRetVal < 0)
        {
            UART_PRINT("Failed to send HTTP GET request.\n\r");
            return lRetVal;
        }
    
    
        lRetVal = readResponse(httpClient);
    
        return lRetVal;
    }
    
    
    int main()
    {
        long lRetVal = -1;
        HTTPCli_Struct httpClient;
    
    
        //
        // Board Initialization
        //
        BoardInit();
    
        //
        // Configure the pinmux settings for the peripherals exercised
        //
        PinMuxConfig();
    
        //
        // Configuring UART
        //
        InitTerm();
    
        //
        // Display banner
        //
        DisplayBanner(APP_NAME);
    
        InitializeAppVariables();
    
        lRetVal = ConnectToAP();
        if(lRetVal < 0)
        {
            LOOP_FOREVER();
        }
    
        lRetVal = ConnectToHTTPServer(&httpClient);
        if(lRetVal < 0)
        {
            LOOP_FOREVER();
        }
    
        //---------------------------
        UART_PRINT("\n\r");
        UART_PRINT("HTTP Get BIN Begin:\n\r");
        lRetVal = HTTPGetBinMethod(&httpClient);
        if(lRetVal < 0)
        {
            UART_PRINT("HTTP Post Get Bin failed.\n\r");
        }
        UART_PRINT("HTTP Get Bin End:\n\r");
        UART_PRINT("\n\r");
    
        //---------------------------
        UART_PRINT("\n\r");
        UART_PRINT("HTTP Get Amud Begin:\n\r");
        lRetVal = HTTPGetAmudMethod(&httpClient);
        if(lRetVal < 0)
        {
            UART_PRINT("HTTP Post Get Amud failed.\n\r");
        }
        UART_PRINT("HTTP Get Amud End:\n\r");
        UART_PRINT("\n\r");
    

    This is the result on terminal :( I redacted my WIFI network name and IP)

    *************************************************
    CC3200 HTTP Client Application
    *************************************************
    
    
    
    Host Driver Version: 1.0.1.14
    Build Version 2.11.0.1.31.1.5.0.2.1.0.3.37
    Device is configured in default state
    Device started as STATION
    [WLAN EVENT] STA Connected to the AP: ------ , BSSID: f0:b0:14:2f:4c:d7
    [NETAPP EVENT] IP Acquired: IP=------ , Gateway=192.168.178.1
    Connected to the AP: ------
    Connection to server created successfully
    
    HTTP Get BIN Begin:
    HTTP getResponseStatus 200
    HTTP Status 200
    Content-Type : application/json=1
    Successfully parsed 17 JSON tokens
    HTTP Get Bin End:
    
    
    HTTP Get Amud Begin:
    HTTP getResponseStatus 404
    File not found.
    HTTP Get Amud End:

    Thankyou!

  • Hi All, any chance of getting help on this matter?

    Thanks

  • Hi Amud,

    I would try to connect to another host such as example.com. This would rule out if the problem is with your code or with your host. Also looking through your code I see you call the function 

    lRetVal = HTTPGetBinMethod(&httpClient);

    But I dont see it defined.

    Regards,

    Rogelio

  • Hi Rogelio

    This is the implementation, and this is exactly the other example I tried - connecting to "httpbin.org",as I said when testing with "httpbin.org" and "/get" it works fine and I get 200 status,

    #define HOST_NAME_BIN "httpbin.org"
    #define GET_REQUEST_URI_BIN     "/get"
    
    static int HTTPGetBinMethod(HTTPCli_Handle httpClient)
    {
    
        long lRetVal = 0;
        HTTPCli_Field fields[4] = {
    
                                    {HTTPCli_FIELD_NAME_HOST, HOST_NAME_BIN},
                                    {HTTPCli_FIELD_NAME_ACCEPT, "*/*"},
                                    {HTTPCli_FIELD_NAME_CONTENT_LENGTH, "0"},
                                    {NULL, NULL}
                                };
        bool        moreFlags;
    
    
        /* Set request header fields to be send for HTTP request. */
        HTTPCli_setRequestFields(httpClient, fields);
    
        /* Send GET method request. */
        /* Here we are setting moreFlags = 0 as there are no more header fields need to send
           at later stage. Please refer HTTP Library API documentaion @ HTTPCli_sendRequest
           for more information.
        */
        moreFlags = 0;
        lRetVal = HTTPCli_sendRequest(httpClient, HTTPCli_METHOD_GET, GET_REQUEST_URI_BIN, moreFlags);
        if(lRetVal < 0)
        {
            UART_PRINT("Failed to send HTTP GET request.\n\r");
            return lRetVal;
        }
    
    
        lRetVal = readResponse(httpClient);
    
        return lRetVal;
    }

    The problem is the is implementing "get" from "www.amudraa.com/terminal", which as I said works via Postman

    Thanks

  • Hi,

    What do you see when you capture communication by network sniffer (Wireshark, tcpdump, etc.)?

    Jan