How can we use API?

Osjtya

Active Member
MailWizz 2.0 Tester
Hello @twisted1919, Thanks for all your support every time. We're again stuck with something, details below:

Our software developer who is making an accounting software in .NET for us needs to send send email with API. But he is confused how to test and proceed.

Your prompt reply will help us more than anything.
 
Hello @twisted1919, Really thanks for your prompt reply. But if I download that package, does that include MailWizz name? And if yes then, I want to remove then how can I do that?

Also can you please point direct file in the package we need to work on for only, SEND email feature via API. Thanks :)
 
Last edited:
@twisted1919 @SQLIK, I'm bit confused now. So please share the answers for below:
  • What required file or folder from the package I need to share with developer to connect MailWizz with our account software? (for SEND email API)
  • Does it also require some changes in website, after changing MailWizzApi word to MailApi?
And finally, how can I stop asking these silly questions? ;)
 
@AC AFD - Any developer that has worked at least one time with a API client will know what to do with the github link i have sent you.
If your dev does not know what to do with that, that's entirely on him.
Does it also require some changes in website, after changing MailWizzApi word to MailApi?
No change in the app, just don't change the http header names, leave the MW prefix as is.

And finally, how can I stop asking these silly questions?
Well, it's required to have some programming experience if you're going through the API stuff. You'll either get some programming skills or have someone that knows this already to handle this task.
 
@AC AFD - Any developer that has worked at least one time with a API client will know what to do with the github link i have sent you.
If your dev does not know what to do with that, that's entirely on him.

No change in the app, just don't change the http header names, leave the MW prefix as is.


Well, it's required to have some programming experience if you're going through the API stuff. You'll either get some programming skills or have someone that knows this already to handle this task.

@twisted1919, Thanks for the prompt reply. Please mention if I'm wrong at any step:
  • Download all files in ZIP from github
  • Extract on my PC
  • Change the word MailWizzApi word to MailApi (without changing MW prefix)
  • Zip all the files & folders (MailWizzApi and examples)
  • Send to developer
Will that be done, am I doing it in right way?
 
@twisted1919, Thanks for the prompt reply. Please mention if I'm wrong at any step:
  • Download all files in ZIP from github
  • Extract on my PC
  • Change the word MailWizzApi word to MailApi (without changing MW prefix)
  • Zip all the files & folders (MailWizzApi and examples)
  • Send to developer
Will that be done, am I doing it in right way?
@twisted1919, Waiting for your reply. Thanks
 
Don't replace a thing, it' seems it complicates things. Just handle the github link to your developer and have him work with that.
 
@twisted1919, Our developer in developing software in C# / .NET. So is there any .Net API? or How we can use PHP API with C#/.NET application.
 
Maybe it could be useful to someone in the future...
Code:
    //For example get lists
    string Url = "http://your-domain-mailwizz.com/api/index.php/lists?page=1&per_page=10";
    string PublicKey = "Your public key"
    string PrivateKey = "Your private key"
    int timestamp = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;

    //get request string to sign
    //don't forget about http encoding
    // %4f - wrong, %4F - ok, space "%20"-wrong, "+" - correctly ( "My first test" to "My+first+test")
    string urlToSing = $"GET {reqUrl}&X-MW-PUBLIC-KEY={PublicKey}&X-MW-TIMESTAMP={timestamp}";
    HMACSHA1 hmac = new HMACSHA1(Encoding.ASCII.GetBytes(PrivateKey)))
    // Compute the hash
    byte[] bSignature = hmac.ComputeHash(Encoding.ASCII.GetBytes(url));
    StringBuilder sbSignature = new StringBuilder();
    foreach (byte b in bSignature) sbSignature.AppendFormat("{0:x2}", b);
    string signature = sbSignature.ToString();

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
    request.Accept = "*/*";
    request.Method = "GET";
    request.Headers.Add("X-MW-PUBLIC-KEY", PublicKey);
    request.Headers.Add("X-MW-TIMESTAMP", timestamp);
    request.Headers.Add("X-MW-SIGNATURE", signature);

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    StreamReader reader = new StreamReader(response.GetResponseStream());
    StringBuilder output = new StringBuilder();
    output.Append(reader.ReadToEnd());
 
Back
Top