UPS API learning to post XML, and retrieving error status from server. Need someone to check code.

I'm trying to figure out how to implement UPS API tools into ASP.NET. I already have Access Key, ID + password from First of all I would like check authentification status. I have find this code from, and past necessary information.

Server response:
<?xml version="1.0"?>
<ErrorDescription>No Access Identification provided</ErrorDescription>

Open in new window

Code behind:
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Partial Class _Default
    Inherits System.Web.UI.Page
    Public Sub Main()
        Dim myxml As String = ""
        myxml = "<?xml version=""1.0""?>"
        myxml = "<AccessRequest xml:lang=""en-US"">"
        myxml = "<merchantAuthentication>"
        myxml = "<AccessLicenseNumber>2**************5</AccessLicenseNumber>"
        myxml = "<UserId>A****3</UserId>"
        myxml = "<Password>D******4</Password>"
        myxml = "</AccessRequest>"

            ' Create a request using a URL that can receive a post. 
            Dim request As WebRequest = WebRequest.Create("")
            ' Set the Method property of the request to POST.
            request.Method = "POST"
            ' Create POST data and convert it to a byte array.
            Dim postData As String = myxml
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
            ' Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded"
            ' Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length
            ' Get the request stream.
            Dim dataStream As Stream = request.GetRequestStream()
            ' Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length)
            ' Close the Stream object.
            ' Get the response.
            Dim response As WebResponse = request.GetResponse()
            ' Display the status.
            Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
            ' Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream()
            ' Open the stream using a StreamReader for easy access.
            Dim reader As New StreamReader(dataStream)
            ' Read the content.
            Dim responseFromServer As String = reader.ReadToEnd()
            ' Display the content.
            TextBox1.Text = responseFromServer
            ' Clean up the streams.
        Catch ex As Exception
        End Try

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    End Sub
End Class

Open in new window

Thank you in advance for help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
Which API are you using? As there are two parts.. a sent item and a response.


confirm the address is correct.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dejandejanovicAuthor Commented:
Well, all APIs have first request authentification, successful communication with this wwwcie (UPS testing enviroment) server.
So, I have start with just first part of below XML, with  authentification, which I have pickup from api zip file.
I have also found ups common error descriptions. And, for my error is:
250005 - No Access and Authentication Credentials provided

Do you have any idea what could be wrong?
Did you use your own UPS access key, ID +pass?
Did you use your own code? If yes, is it possible to post here?

Template code:
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<?xml version="1.0"?>
<AddressValidationRequest xml:lang="en-US">
      <CustomerContext>Your Test Case Summary Description</CustomerContext>
    <AddressLine>AIRWAY ROAD SUITE 7</AddressLine>	
    <PoliticalDivision2>SAN DIEGO</PoliticalDivision2>

Open in new window

dejandejanovicAuthor Commented:
I was expect more help here.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.