2

I need to use HTTP Post to send a a string array like so...

        Dim wc As New Net.WebClient
        Dim NC As New Specialized.NameValueCollection
        NC.Add("api_user", "some user")
        NC.Add("api_key", "some key")
        NC.Add("from", "me@world.com")
        NC.Add("subject", "testing...")
        NC.Add("body", "testing...again")
        NC.Add("to", string_array)

i have tried several methods, but i keep getting - The remote server returned an error: (400) Bad Request.

I'm posting to SendGrid via their WebAPI

Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157

2 Answers2

2

Just found a solution.

    For i = 0 To addresess.Length - 1
        NC.Add("to[" & i & "]", addresess(i))
    Next

use an index and the same keyName

Help came from here : POST'ing arrays in WebClient (C#/.net)

Community
  • 1
  • 1
Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157
0

If you are receiving a 404, then that most likely means that either the URL in your application for their service is incorrect or the service is not currently running. Can you copy the URL that is in your application and paste it into a browser address area to see if you can access it directly?

competent_tech
  • 44,465
  • 11
  • 90
  • 113
  • Ah, that makes a difference. According to comments in this post http://stackoverflow.com/questions/5227425/sendgrid-api-error-codes-and-messages that could mean a bad user name and password. – competent_tech Oct 29 '11 at 21:17
  • hi, no my authentication is correct. i found a solution http://stackoverflow.com/questions/3942427/posting-arrays-in-webclient-c-net – Charles Okwuagwu Oct 29 '11 at 21:22