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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:14:03+00:00 2026-05-18T00:14:03+00:00

I am trying to send a POST request to add some content to an

  • 0

I am trying to send a POST request to add some content to an API box. The rules are that the body format should be XML(values must be XML-escaped), HTTP Method (post), requires authentication(yes), request content(content-type: “application/xml”

<entries?
  <entry tag="some_tag">
   <value>XML-escaped-entry belongs here</value>
  </entry>
  <entry tag="some_tag">
   <value>XML-escaped-entry belongs here</value>
....
...

 </entries>

I send the request as follows and get a 400 bad request error. It worked when I entered one value for entry.

 For i As Integer = 0 To searchItems.Count - (1000 - max)
                data = data + "<entries><entry><value>" & searchItems.Item(i) & "</value></entry></entries>" & vbNewLine
            Next
            If uri.Scheme = uri.UriSchemeHttps Then
                Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
                request.Method = method__1
                request.ContentLength = data.Length
                request.ContentType = "application/xml"
                request.Credentials = New System.Net.NetworkCredential("xxx@xxx.com", "xxxxxx")
                Dim writer As New StreamWriter(request.GetRequestStream)
                writer.Write(data)
                writer.Close()
                Dim oResponse As HttpWebResponse = request.GetResponse()
                Dim reader As New StreamReader(oResponse.GetResponseStream())
                Dim tmp As String = reader.ReadToEnd()
                oResponse.Close()
            End If

additional rules:
-Best practice is to incrementally add and remove changes to your entry list instead of deleting/recreating the entire list each time a change is necessary.
-New entries are placed at the top of the queue for polling and are processed in a LIFO manner.

  • 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-18T00:14:03+00:00Added an answer on May 18, 2026 at 12:14 am

    You need to Look for and encode special characters during your loop. Something along the lines of:

     For i As Integer = 0 To searchItems.Count - (1000 - max)
                data = data + "<entries><entry><value>" & encodeEntry(searchItems.Item(i)) & "</value></entry></entries>" & vbNewLine
     Next
    
     Private Function encodeEntry(ByVal entry As String) As String
         Dim returnValue As String = entry
    
         ' Replace the special characters
         returnValue = returnValue.Replace("&", "&amp;")
         returnValue = returnValue.Replace("""", "&quot;")
         returnValue = returnValue.Replace("'", "&apos;")
         returnValue = returnValue.Replace("<", "&lt;")
         returnValue = returnValue.Replace(">", "&gt;")
    
         ' return the escaped string
         return returnValue
     End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send a POST request to a rails scaffold controller which
I'm trying to send a post request to Parse: https://parse.com/docs/rest#objects-creating . Can't get it
I have a problem when trying to send a POST request. The sending method
I am receiving a NullPointerException when trying to send a POST request to a
Trying to find a way to send a POST HTTPS request from Python to
I'm trying to send post using API feed. I set fields: message , link
i'm trying to use ASIFormDataRequest to send post request. But when I import the
I am trying to output POST-data that I send from an android phone, however
I am trying to send an URL-encoded post to a REST API implemented in
I'm trying to send a POST request to a web app. I'm using the

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.