Passing Parameters in HTTP POST Method for Tizen Native Applications

Original Created Sep 19, 2017 | Regeneration Apr 22, 2026

I'm developing a Tizen native application that needs to make HTTP requests (both GET and POST methods). I've referenced the official documentation on HTTP requests (https://developer.tizen.org/development/guides/native-application/connectivity-and-wireless/internet-and-contents-downloads/http).

While the GET method works fine, I'm having trouble with the POST method. I'm not getting a successful response, which I believe is due to incorrect parameter passing. Currently, I'm passing parameters like this:

const char* post_msg = "email=abcd@gmail.com&password=12312345678";

Could anyone help me understand the correct way to pass parameters in a POST request?

Problem Understanding

The issue occurs when trying to pass parameters in an HTTP POST request in a Tizen native application. While the request structure is correct, the parameter passing method needs adjustment.

Solution Methods

  1. Using http_transaction_request_write_body():

    • This is the proper way to write POST body data in Tizen native applications
    • Ensure you set the correct Content-Type header (typically "application/x-www-form-urlencoded")
  2. Parameter Format:

    • Make sure parameters are properly URL-encoded
    • Use the standard key=value&key=value format

Code Examples

Here's a complete example of how to properly make a POST request:

#include <http.h>

void make_post_request() {
    http_transaction_h transaction;
    http_request_h request;
    const char* url = "https://your-api-endpoint.com/login";
    const char* post_data = "email=test%40example.com&password=secure123";
    
    // Create HTTP request
    http_request_create(&request);
    http_request_set_method(request, HTTP_METHOD_POST);
    http_request_set_url(request, url);
    http_request_set_header(request, "Content-Type", "application/x-www-form-urlencoded");
    
    // Create transaction
    http_transaction_create(request, &transaction);
    http_transaction_set_write_cb(transaction, write_callback, NULL);
    http_transaction_set_read_cb(transaction, read_callback, NULL);
    
    // Write POST data
    http_transaction_request_write_body(transaction, post_data, strlen(post_data));
    
    // Submit transaction
    http_transaction_submit(transaction);
    
    // Cleanup
    http_transaction_destroy(transaction);
    http_request_destroy(request);
}

Additional Tips

  • Always check return values from HTTP API calls
  • Use proper error handling
  • For complex data, consider using JSON format instead of form-urlencoded
  • Remember to URL-encode special characters in your parameters

Customize your cookie preferences

You can enable or disable non-essential cookies. Essential cookies are always on to ensure the site works properly and to keep you signed in.

Necessary

These cookies are necessary for the website to function properly and cannot be switched off. They help with things like logging in and setting your privacy preferences.

Always on

Analytics

These cookies help us improve the site by tracking which pages are most popular and how visitors move around the site.

Enable analytics cookies
Public Forum Public Forum
Employees only. Please sign in with your company account.