Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:23:15+00:00 2026-06-15T04:23:15+00:00

I am trying to send a HTTP-POST request to a key-value pair using the

  • 0

I am trying to send a HTTP-POST request to a key-value pair using the POST method, which in return send me a jSON response.

CODE

//[dictionnary setObject:@"tId" forKey:@"serialnumber"];
 NSMutableDictionary *dictionnary = [NSMutableDictionary dictionary];
         [dictionnary setObject:[NSString stringWithFormat:@"tId"] forKey:@"serialnumber"];
   [dictionnary setObject:[NSString stringWithFormat:@"tname"]  forKey:@"mobileimei"];
    [dictionnary setObject:[NSString stringWithFormat: @"tprice"] forKey:@"submerchantguid"];
    [dictionnary setObject:[NSString stringWithFormat: @"tquan"] forKey:@"transactionid"];
    [dictionnary setObject:[NSString stringWithFormat: @"tquan"] forKey:@"emailid"];
    [dictionnary setObject:[NSString stringWithFormat: @"tquan"] forKey:@"mobileno"];
    [dictionnary setObject:[NSString stringWithFormat: @"tquan"] forKey:@"signature"];
    [dictionnary setObject:[NSString stringWithFormat:@"tquan"] forKey:@"photo"];


 NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionnary
                                                       options:kNilOptions
                                                         error:&error];
    NSLog(@"Error is %@",error);

   NSString *urlString = @"MY_POST_URL/transaction/model/transactionsuccess";
    //NSString *urlString = @"http://yahoo.com";
    NSURL *url = [NSURL URLWithString:urlString];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"POST"];

    [request setHTTPBody:jsonData];
    NSURLResponse *response = NULL;
    NSError *requestError = NULL;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError];
    NSLog(@"request Error %@",requestError);
    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] ;
    NSLog(@"%@", responseString);

OUTPUT

inside submitinfo method
2012-11-29 12:13:02.238 ReaderDeployment[1568:11f03] Error is (null)
2012-11-29 12:13:03.005 ReaderDeployment[1568:11f03] request Error (null)
2012-11-29 12:13:03.006 ReaderDeployment[1568:11f03] <!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>PHP notice</title>

<style type="text/css">
/*<![CDATA[*/
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent;margin:0;padding:0;}
body{line-height:1;}
ol,ul{list-style:none;}
blockquote,q{quotes:none;}
blockquote:before,blockquote:after,q:before,q:after{content:none;}
:focus{outline:0;}
ins{text-decoration:none;}
del{text-decoration:line-through;}
table{border-collapse:collapse;border-spacing:0;}

body {
    font: normal 9pt "Verdana";
    color: #000;
    background: #fff;
}

h1 {
    font: normal 18pt "Verdana";
    color: #f00;
    margin-bottom: .5em;
}

h2 {
    font: normal 14pt "Verdana";
    color: #800000;
    margin-bottom: .5em;
}

h3 {
    font: bold 11pt "Verdana";
}

pre {
    font: normal 11pt Menlo, Consolas, "Lucida Console", Monospace;
}

pre span.error {
    display: block;
    background: #fce3e3;
}

pre span.ln {
    color: #999;
    padding-right: 0.5em;
    border-right: 1px solid #ccc;
}

pre span.error-ln {
    font-weight: bold;
}

.container {
    margin: 1em 4em;
..........

Please correct me with what is wrong in the code.I have also tried sending the details for all values using

[dictionnary setObject:@"tId" forKey:@"serialnumber"];

format also. I am getting no error,still the expected jSON response is not achieved.Backend only intakes the information, and throws status as “0” OR “1”.Instead some weird output is being displayed, I suppose it is css script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:23:16+00:00Added an answer on June 15, 2026 at 4:23 am

    You have error on the server side, you can not use the json directly you have to convert json to array json_decode firstly then use the values of the array

    this is how to convert the php json to array http://php.net/manual/en/function.json-decode.php

    Also the to return json you should format your php array again to JSON encode

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a simple http post which will send a json
I'm trying to send the xml to another webserver through Restclient's http POST request.This
I am trying to send a simple ajax post request using Mootools but I'm
I'm trying to send post request using rails controller, however i faced issue, when
I'm trying to send a HTTP POST request to a Google server and get
I am trying to send a POST request to a server using AFNetworking, and
I'm trying to send a POST request to a PHP script (http://mywebsite/index/test/ in this
I'm trying to send post request to web service which have an email and
I am trying to post two parameters using HTTP POST-request to http://foo.bar.com/submit.jsp . This
I'm trying to send a http get request in a php file to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.