element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
STM32F4DISCOVERY Expansion Boards
  • Products
  • Dev Tools
  • STM32F4DISCOVERY Expansion Boards
  • More
  • Cancel
STM32F4DISCOVERY Expansion Boards
Forum SN8200 (STM32F4DIS-WIF) HTTP Post to Thingspeak (Not Working)
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STM32F4DISCOVERY Expansion Boards to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 2 replies
  • Subscribers 5 subscribers
  • Views 587 views
  • Users 0 members are here
  • stm32f4dis-wifi
  • wifi
  • sn8200
  • wireless
  • stm32f4discovery
Related

SN8200 (STM32F4DIS-WIF) HTTP Post to Thingspeak (Not Working)

mroussin
mroussin over 11 years ago

I am trying to send an HTTP Post to a channel I created on Thingspeak.com.  I am using the provided code for the Keil environment and have tried multiple different things to try to post a value to my channel.  Below is the configuration of the sendHttpPostDemo() function.  The only modification I made was to change the content type from "text/html" to "application/x-www-form-urlencoded".  When I run the application I type following

 

e (selects HTTP Post)

http://api.thingspeak.com (server)

/update (uri)

mykey&field1=90

 

I get the following message:

 

HTTP RSP code: 21, seq #13

 

When I look up the code this is decimal 21 which is 0x15.  According to the SNIC Serial Interface manual this represents "SNIC_INVALID_ARGUMENT".  There is no more detail regarding the invalid argument.

 


image


I am able to post values to Thingspeak using Mozilla HTTP Poster program.  This appears to be something directly related to how the code is managing the request for the post.  Any help would be appreciated.



sendHttpPostDemo Function that was slightly modified

 

int sendHttpPostDemo(char *domain)

{

    cchar content[256]={0};

    char tmp[100];

    char method = 1; //POST

    char contentType[] = "application/x-www-form-urlencoded";  // Was "text/html"

        char otherHeader[] = "Accept-Language: en-US\r\n";

    unsigned char timeout = 10;

 

    printf("Enter URI after the server name: ([CR] to accept %s)\n\r", uri);

    scanf("%s",tmp);

    printf("\n\r");

    if (strlen(tmp))

        strcpy(uri, tmp);

    printf("Enter content to POST: \n\r");

        scanf("%s",content);

    printf("\n\r");

    if (strlen(uri)==0)

        strcpy(uri, "/add.php");

    return fillNSendHttpReq(seqNo++, domain, uri, method, contentType, otherHeader, strlen(content), content, timeout, 0,0);

    }

  • Sign in to reply
  • Cancel
  • mroussin
    0 mroussin over 11 years ago

    Just as a follow up.  I am able to send an HTTP post to "www.murata-ws.com/" site.  See pic below, there is additional info that was printed out below the "Content:" portion as well.  So I am able to post, but for some reason I cannot post to my Thingspeak channel.

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mroussin
    0 mroussin over 11 years ago in reply to mroussin

    So I found my issue that I have been banging my head over all afternoon.  The solution is quite simple.  When I am posting to the server I need to exclude the "HTTP://" portion.  So when it asks for the server location you just need to type "api.thingspeak.com".

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube