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 9225667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:38:12+00:00 2026-06-18T04:38:12+00:00

I am attempting to create json data to send to a server via an

  • 0

I am attempting to create json data to send to a server via an HTTP POST request. The server will only accept a specific format of JSON, otherwise it will return an error. I can successfully create and upload the JSON file to the server, however I am getting the following error because I have not formatted my JSON incorrectly:

JSON Error Message: {
    code = "-2";
    message = "Validation error: {\"message\":{\"to\":[\"Please enter an array\"]}}";
    name = ValidationError;
    status = error;
}

As you can see, the server needs a complex JSON format with an Array of Values and Keys but I’m not sure how to do that. Below is my current code to create the JSON data:

//Create Array With TO Values
NSDictionary *toField = @{@"email" : emailField.text};
//Create Dictionary Values                
NSDictionary *messageContent = @{@"subject" : @"APPNAME Registration Complete", @"from_email" : @"email@domain.com", @"to" : toField};
NSDictionary *mandrillValues = @{@"key" : @"APPKEY",
                                 @"redirect_url" : @"PRIVATE-URL",
                                 @"template_name" : @"app-registration",
                                 @"template_content" : [NSNull null],
                                 @"message" : messageContent
                                };

NSData* jsonData = [NSJSONSerialization dataWithJSONObject:mandrillValues options:NSJSONWritingPrettyPrinted error:nil];

According to the server, I need an array with keys and values, similar to a nsdictionary. When I use an NSArray, though, I can’t add values / keys. Any ideas on how I should go about doing this? Below is an example of the JSON format that the server will accept, am I doing everything right to follow this format? If not, what do I need to change to match the format?

{
"key": "example key",
"template_name": "example template_name",
"template_content": [
    {
        "name": "example name",
        "content": "example content"
    }
],
"message": {
    "text": "example text",
    "subject": "example subject",
    "from_email": "message.from_email@example.com",
    "from_name": "example from_name",
    "to": [
        {
            "email": "example email",
            "name": "example name"
        }
    ],
}}
  • 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-18T04:38:14+00:00Added an answer on June 18, 2026 at 4:38 am

    Looks like the “to” field expects an array. Unless the variable toField is an NSArray that contains dictionaries with keys and values as described, you’re going to get a JSON that’s not exactly like the one you want.

    I would suggest outputting the description of the outgoing JSON to see exactly where there are differences.

    Update
    I saw the addition to your question –

    NSDictionary *toField = @{@"email" : emailField.text};
    

    Does not create an array. Try:

    NSArray *toField = @[@{@"email" : emailField.text}];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to use JSON to send data between the browser and my
I'm returning data via JSON and attempting to loop through the JSON dataset to
I'm attempting to send an HTTP POST to a Rails 3 Application. Currently all
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a CustomControl which will have various properties affected by an
I will be retrieving multiple blocks of json data over time and deserializing them
I'm attempting to create a client/server web-app. The client software is written in Objective-C
I'm using JQuery to make a JSON request to access data on a private
I am attempting to create a class in vb.net from the below JSON example.
I'm attempting to send a piece of data through jQuery .ajax() to a PHP

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.