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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:06:20+00:00 2026-05-21T05:06:20+00:00

I’m trying to upload a multi-line text file to be GeoCoded by BING. 1,en-US,,16630

  • 0

I’m trying to upload a multi-line text file to be GeoCoded by BING.

1,en-US,,16630 Redmond Way,WA,USA,,,Redmond,98052,,,,,,,,,,,,,,,,,,,,,,
2,en-US,,16552 NE 74th St,WA,,,,Redmond,,,High,,,,,,,,,,,,,,,,,,,,,,
3,en-US,Seattle Space Needle,,,,,,,,,,,,,,,,,,,,,,,,,,,,
4,en-US,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
5,en-US,,W Jefferson Blvd,CA,,,,Los Angeles,90007,,,,,,,,,,,,,,,,,,,,,,,,
6,en-US,,,CA,,,,Los angeles,,,,,,,,,,,,,,,,,,,,,,,,,
7,en-ca,Montreal Canada,,,,,,,,,,,,,,,,,,,,,,,,,,,,
8,en-CA,,444 Kirkpatrick Cres NW,AB,Canada,,,Edmonton,,,,,,,,,,,,,,,,,,,,,,,,
9,en-gb,BD4 9JB,,,,,,,,,,,,,,,,,,,,,,,,,,,,
10,en-us,,,,,,,,,,,,,,,,,,,,,,,,,,,,47.673099,-122.11871
11,en-ca,,,,,,,,,,,,,,,,,,,,,,,,,,,,53.48021728,-113.4030925
12,en-gb,,,,,,,,,,,,,,,,,,,,,,,,,,,,53.77848387,-1.719561517

I’m using TIdHTTP at the moment, but it seems that the line breaks in the text file are removed when transmitting the file as they (Bing) only ever geocode the first line of the file and the rest is ignored.

lHTTP := TIdHTTP.Create(nil);
...

//Build the http request string
HTTPRequest := 'http://spatial.virtualearth.net/REST/v1/Dataflows/Geocode?input=csv&output=xml&key=' + BingKey;

//Setup the HTTP request parameters
lHTTP.Request.ContentType := 'text/plain';
lHTTP.Request.Method := 'POST';

//Send the request to Bing. Result in XMLResult StringStream
lHTTP.Post(HTTPRequest, lParamList, XMLResult);

The following example is from Microsoft but I’m not enough of an expert to adapt the HTTPWebRequest part using the stream to Delphi.

//Parameters:
//   dataFilePath: The path to the file that contains the spatial data to geocode.
//   dataFormat: The format of the input data. Possible values are xml, csv, tab and pipe.
//   key: The Bing Maps Key to use for this job. The same key is used to get job status and download results.
//   description: Text that is used to describe the geocode dataflow job.
//Return value : A URL that defines the location of the geocode dataflow job that was created.
static string CreateJob(string dataFilePath, string dataFormat, string key, string description)
{
    //Define parameters for the HTTP request
    //
    // The 'Content-Type' header of the HTTP Request must be "text/plain" or "application/xml"
    // depending on the input data format.
    //
    string contentType = "text/plain";
    if (dataFormat.Equals("xml", StringComparison.OrdinalIgnoreCase))
        contentType = "application/xml";

    StringBuilder queryStringBuilder = new StringBuilder();

    //
    // The 'input'(input format) and 'key' (Bing Maps Key) parameters are required.
    //
    queryStringBuilder.Append("input=").Append(Uri.EscapeUriString(dataFormat));
    queryStringBuilder.Append("&");
    queryStringBuilder.Append("key=").Append(Uri.EscapeUriString(key));

    if (!String.IsNullOrEmpty(description))
    {
        //
        // The 'description' parameter is optional.
        //
        queryStringBuilder.Append("&");
        queryStringBuilder.Append("description=").Append(Uri.EscapeUriString(description));
    }

    //Build the HTTP URI that will upload and create the geocode dataflow job
    UriBuilder uriBuilder = new UriBuilder("http://spatial.virtualearth.net");
    uriBuilder.Path = "/REST/v1/dataflows/geocode";
    uriBuilder.Query = queryStringBuilder.ToString();

    //Include the data to geocode in the HTTP request
    using (FileStream dataStream = File.OpenRead(dataFilePath))
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uriBuilder.Uri);

        //
        // The HTTP method must be 'POST'.
        //
        request.Method = "POST";
        request.ContentType = contentType;

        using (Stream requestStream = request.GetRequestStream())
        {
            byte[] buffer = new byte[16384];
            int bytesRead = dataStream.Read(buffer, 0, buffer.Length);
            while (bytesRead > 0)
            {
                requestStream.Write(buffer, 0, bytesRead);

                bytesRead = dataStream.Read(buffer, 0, buffer.Length);
            }
        }

        //Submit the HTTP request and check if the job was created successfully.
        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            //
            // If the job was created successfully, the status code should be
            // 201 (Created) and the 'Location' header should contain a URL
            // that defines the location of the new dataflow job. You use this
            // URL with the Bing Maps Key to query the status of your job.
            //
            if (response.StatusCode != HttpStatusCode.Created)
                throw new Exception ("An HTTP error status code was encountered when creating the geocode job.");

            string dataflowJobLocation = response.GetResponseHeader("Location");
            if (String.IsNullOrEmpty(dataflowJobLocation))
                throw new Exception ("The 'Location' header is missing from the HTTP response when creating a goecode job.");

            return dataflowJobLocation;
        }
    }
}
  • 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-05-21T05:06:21+00:00Added an answer on May 21, 2026 at 5:06 am

    Probably TStringList is changing the content of the input file. At least some of the bytes. It would be better to post the data as pure stream, either as memory or file stream.

    Indy has the following overloaded methods for posting:

    function Post(AURL: string; ASource: TStrings): string; overload;
    function Post(AURL: string; ASource: TStream): string; overload;
    function Post(AURL: string; ASource: TIdMultiPartFormDataStream): string; overload;
    procedure Post(AURL: string; ASource: TIdMultiPartFormDataStream; AResponseContent: TStream); overload;
    procedure Post(AURL: string; ASource: TStrings; AResponseContent: TStream); overload;
    
    {Post data provided by a stream, this is for submitting data to a server}
    procedure Post(AURL: string; ASource, AResponseContent: TStream); overload;
    

    Several of them are appropriate for posting raw streams.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to render a haml file in a javascript response like so:
I have a reasonable size flat file database of text documents mostly saved in
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.