• AVR Freaks

Hot!HTTP POST on ATSAMW25 (or similar)

Author
d.
Junior Member
  • Total Posts : 113
  • Reward points : 0
  • Joined: 2009/08/05 00:10:47
  • Location: 0
  • Status: offline
2019/04/22 13:13:21 (permalink)
0

HTTP POST on ATSAMW25 (or similar)

Does anyone have any experience using the http_client_send_request() function to POST to a web site?  I'm looking for examples or help in populating the http_entity structure (and making it work).  I thought all I would need to do is populate the priv_data field with the string I want to post, but that doesn't work.  The string is in a static array so I think read and close can be NULL.  Not sure about length.
 
The only example I can find is the HTTP downloader, but that doesn't use the entity structure at all.
 
???
 
Thanks,
 
Dave
#1

4 Replies Related Threads

    maxruben
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: HTTP POST on ATSAMW25 (or similar) 2019/04/24 13:22:19 (permalink)
    0
    I have never used the http_client_send_request() but take a look at postman. It is a tool to build post and get request (and test them). There you can se how the http headers can use and test a payload (body).
     
    /Ruben
    #2
    d.
    Junior Member
    • Total Posts : 113
    • Reward points : 0
    • Joined: 2009/08/05 00:10:47
    • Location: 0
    • Status: offline
    Re: HTTP POST on ATSAMW25 (or similar) 2019/04/24 17:32:19 (permalink)
    0
    Thanks Ruben.  I do have an API (custom) which allows me to test various POST and GET messages to my web site.  I'm trying to figure out why the Atmel code does not generate the messages that I can verify in that API.  I keep digging lower and lower into their code, but haven't found the reason the data isn't right yet.  I was hoping to find a working solution which I could compare against my implementation.
     
    I'll keep looking.
     
    Thanks!
     
    Dave
    #3
    d.
    Junior Member
    • Total Posts : 113
    • Reward points : 0
    • Joined: 2009/08/05 00:10:47
    • Location: 0
    • Status: offline
    Re: HTTP POST on ATSAMW25 (or similar) 2019/04/25 13:08:59 (permalink)
    0
    BUG IN THE ATMEL HTTP CODE!
     
    (I would hope this gets somebody's attention. Smile: Smile  )
     
    When you call into one of the http functions to send data, a local static array is allocated using some standard initializer.  Later in the routine, the size of the data is determined as a return value in a function copying the data from one buffer into the local array.  If the size is > what was allocated before the copy, CRASH!
     
    One baby step forward, but still not out of the woods.
    #4
    d.
    Junior Member
    • Total Posts : 113
    • Reward points : 0
    • Joined: 2009/08/05 00:10:47
    • Location: 0
    • Status: offline
    Re: HTTP POST on ATSAMW25 (or similar) 2019/05/07 09:19:46 (permalink)
    0
    OK, finally got to the bottom of this.  There were 2 issues:
    1. It was my misunderstanding on how the entry_read() function should be implemented. I don't understand why all of the example code to populate the entity structure is not included with the ASF example projects.
    2. My project uses an https GET to get information from the cloud, then uses https POST to send data to the cloud. For some reason, the https GET was working but the POST was failing. After I re-flashed my certs, the POST started working for only a short time, them failed again. I re-flashed the certs again, and POSTs have been working since. I have no idea what caused this. I was switching between a couple of different AtmelStudio projects on the same board, but I would think that if one of those broke the certs, both GET and POST would fail, not just POST.
    So hopefully, no more problems.
     
    Thanks for listening.
     
    d.
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5