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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:53:23+00:00 2026-06-08T13:53:23+00:00

I have some code to send a url to a remote server. If I

  • 0

I have some code to send a url to a remote server. If I do not encode the url, it works perfectly. But if I encode the url, it does not work. So I am pretty sure something is not right with the way I encode the url query string.

Here is my code:

        // URL TO BE SUBMITTED.
        NSString *urlString = 
        @"http://www.mydomain.com/test.php?";

        // NOW CREATE URL QUERY STRING    
        NSString *unencoded_query_string = 
        @"name=%@&user_id=%@&person_name=%@&person_email=%@&privacy=%@";

// PUT PREVIOUSLY SET VALUES INTO THE QUERY STRING
        NSString *unencoded_url_with_params = 
        [NSString stringWithFormat:unencoded_query_string, business , user_id , name , email , privacy_string]; 

        // ENCODE THE QUERY STRING
        NSString *escapedString = (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(
                                                                                      NULL,
                                                                                      (__bridge CFStringRef)unencoded_url_with_params,
                                                                                      NULL,
                                                                                      (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                                                      kCFStringEncodingUTF8);

        // NOW APPEND URL TO QUERY STRING
        NSString *full_encoded_url_string = 
        [urlString  stringByAppendingString: escapedString];

and then I send this string to the server, and the server does have the correct request file invoked, but isn’t able to read the parameters.

Would anyone know what I doing incorrectly here? I am using arc by the way.

Thanks!

  • 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-08T13:53:24+00:00Added an answer on June 8, 2026 at 1:53 pm

    I think you probably want to escape each param, not the entire request. Basically you want to escape ampersands, spaces etc that show up in your get variables. Your encoded URL probably looks like this:

    http://www.mydomain.com/test.php?name%3DPeter%20Willsey%26user_id%3DUSERID%26person_name%3DPeter%20Willsey%26person_email%3Dpeter%40test.com%26privacy%3D1
    

    and it should look like this:

    http://www.mydomain.com/test.php?name=Peter%20Willsey&user_id=25&person_name=Peter%20Willsey&person_email=peter%40test.com&privacy=1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have some sample code showing how to POST to a URL using
I have a some code to ajax upload . its send request to my
I have some web application that uses jQuery to send AJAX requests to server.
I have put together some code from various sources but javascript is somewhat unknown
So I have a bookmarklett that seems to not work on some sites. Here's
I have to connect to some server with URL host/getdata?reqtype=generate&login=xxx&pass=xxx&dest=yyy using SSL. I'm using
I have some code in a javascript file that needs to send queries back
Here's my problem I have some code and I'm using it to send an
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .
I have some code that will change the background color of a specific label

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.