1
Web Services integration
Question asked by Erik White - March 7 at 8:47 PM
Answered
Hey we are working on putting up a web interface over smartermail, and have been playing around with the API calls.
mail.handleitmail.com is our domain on our Windows 2012 server, handleitmail.com/test.html is our regular domain im testing trying to send an api call to create a user/get a user/ do anything. I am using the JQuery/Ajax HTTP requests, as documented in the API doco, and there are two main issues I am facing:
1. identifying the correct file path (you can probably inspect document and see the error for the path that is currently there)
2. Authentication tokens
In order to isolate the issue, I chose an API call that claimed authentication was not necessary, so I know I have a separate issue of identifying the correct path. Both domain and smartermail install reside on the same server. I can provide additional information regarding the path if necessary.
 
Has anyone had luck getting web services API calls to respond?

7 Replies

Reply to Thread
0
Matt Petty Replied
March 8 at 9:28 AM
Employee Post
var jqxhr = $.post( "/api/v1/auth/authenticate-user",{ username: "fullemail@address.com", password: "pass" } ,  function(resp) {
		alert( "success" );
		console.log(resp);
	}, "json")
	.fail(function() {
		alert( "error" );
	});
Here is an example, you may have to adjust the endpoint depending on your environment. This call will return you an object that you can inspect in chrome debugger or whatever webbrowser you use.
Matt Petty
Software Developer
SmarterTools Inc.
(877) 357-6278
www.smartertools.com
0
Erik White Replied
March 9 at 5:00 PM
Thanks for getting back, and yeah this is the call I have set up, taken directly from the API doco : 

function apiCall(){
var url = "handleitmail.com/" + "api/v1/api-documentation/tree";   

$.ajax({
    url: url,
    type: 'GET',
    dataType: 'json',
    success: function (data) {
        alert("this works");
    }
});   
}

which can be seen on the link I provided. Its the part about the 'endpoint path depending on my environment' which is my issue. 'Documentation tree' is an API call that claims to not require authentication, and all I am trying to get is a 'success' alert to let me know there is life on the other side of my attempts. How can I better understand exactly where my endpoint is?
0
Erik White Replied
March 12 at 1:26 PM
Oh no reading a response is not what I meant to ask about, I mean to ask for a way of identifying the endpoint for the call itself. As of now I cannot make calls at all, I can tell you the file structure that smartermail is in on our server, could you tell me what I need to call my endpoint?
0
Erik White Replied
March 12 at 1:27 PM
How can i interpret the file path that the file resides in to create my endpoint path?
0
Matt Petty Replied
March 13 at 8:16 AM
Employee Post
If you go here (and wait for a bit) https://mail.smartertools.com/Documentation/api this should list all the APIs that you can access.
I'm not sure if I understand your question, these APIs aren't file paths, they don't reside on the file system. But using that link above will tell you what they are.
Matt Petty
Software Developer
SmarterTools Inc.
(877) 357-6278
www.smartertools.com
0
Erik White Replied
March 13 at 9:43 PM
Grady Werner had a pretty on-point response. Thank you.
Okay so Matt I know the calls have an 'endpoint' of some ASMX file which has a physical location on my server. That physical location has a path to it. The tip Grady gave worked-ish and now I am getting  a "No 'Access-Control-Allow-Origin' header is present on the requested resource. " error 401 on the call. Again this can all be seen on our test site handleitmail.com/test.html just click the button and look at the console.log.
Seems as if there are some CORS issues going on serverside. I enabled CORS (so I think) on my ajax call (did a little "crossDomain:true") so any word on how to enable CORS on the resource? that is tomorrows mission for me atleast
0
Erik White Replied
March 17 at 8:45 PM
Hey Matt, any word on the CORS configuration? is there any user-level way of adjusting CORS? 
Thanks for helping

Reply to Thread