I’m trying to create emails with the API of Selzy. I can use Postman fine:
A simple GET call copied into the browser works fine:
When try to use a UrlConnection I only get access denied:
Dim FormData As New JSONItem
FormData.Value("api_key") = "65oh666xxx"
FormData.Value("sender_name") = "Beatrix Willius from Moth Software"
FormData.Value("sender_email") = "firstname.lastname@example.org"
FormData.Value("subject") = "test subject"
FormData.Value("body") = "<html><body>test body</body></html>"
FormData.Value("list_id") = "1"
dim theResult as String = theSocket.SendSync("POST", "https://api.selzy.com/en/api/createEmailMessage")
dim ResultDictionary as Dictionary = ParseJSON(theResult)
if ResultDictionary.HasKey("error") then
MessageBox("There was an error when trying to create an email: " + EndOfLine + EndOfLine + ResultDictionary.Value("error"))
What am I doing wrong?
What I think the documentation is suggesting for POST is to send form data. You can do this with the free open source class from Einhugur
Let us know if you get stuck or it doesn’t work.
Edit: Here’s all I could find about GET / POST and format
Selzy’s API is a bit strange, it looks like everything related to the email should be included in the URL parameters. Other APIs use POST data.
Selzy is expecting everything in the URL parameters, just like you did in Postman.
Are you sure the server is expecting a json?
Why not send it all the params in the URL like with Postman?
The “format” param you send in Postman is to tell the server the format of the response you are epecting.
Also, it looks like Selzy is for sending email campaigns, as in sending one or more emails to a group of people.
Is that really what you need @Beatrix_Willius ?
If you are looking for transactional emails (as in sending a different email to each person) it looks like you will need to use https://unione.io which is owned or a partner of Selzy.
@Jeremie_L : Selzy also allows POST data which is I’m trying to get working. GET works fine. I’m trying to send bulk emails to a list. I want to get rid of MailChimp where I still use RSS to email.
@Ivan_Tellez : No, I’m not sure if this is needed here.
@Tim_Parnell : I get the same result as before:
Dim FormData as MultipartFormDataContent = new MultipartFormDataContent()
FormData.Add("sender_name", "Beatrix Willius from Moth Software")
FormData.Add("subject", "test subject")
FormData.Add("body", "<html><body>test body</body></html>")
Dim result as String = theSocket.SendSync("POST", "https://api.selzy.com/en/api/createEmailMessage")
Do you have a link to the documentation that talks about POST? I couldn’t find it, but reading it might help understand the exact format.
See my post above, it’s all I could find about the optional POST method.
Can you show the raw request Postman sends? I know Paw/RapidAPI can show that, it would be helpful and could illustrate the difference in requests. You’re welcome to send it privately if necessary.
All parameters should be encoded in UTF-8. In the example above the parameters are given in the GET request, but you can send them through POST as well. Moreover, we strongly recommend that you send the api_key parameter through POST to ensure it’s not saved in proxy servers logs.
Here is the raw command from Postman:
I don’t think that this is form data.
Yea if it was Formdata then your parameters in your Postman would be in the body section like this:
So, yes it is not formdata. And More like just parameters, like Jeremie was hinting I think.
You are correct, that looks like GET parameters to me…
Ah, I don’t use Postman so I wasn’t sure where those items ended up. I use Paw / RapidAPI
From their docs:
The list of parameters for the method called is transferred in params . Parameters can be transferred either via a GET request or via POST. You are strongly recommended to use only POST requests, since the data transferred in them is not stored in logs of the servers engaged in the connection. This increases the security of your work through API.
So you could use “x-www-form_urlencoded” (or even “mutlipart/form-data”)
var params As string = "param1=value1¶m2=value2¶m3=value3"
// you may be required to EncodeURLComponent all of the values.
Thanks for your help, guys.