Contents
Authentication

There are two ways to send an authenticated request to the MapLarge API. You can request a temporary access token or you can send your user name and password directly with your request.

Which method should you use?

Both methods are very similar. The only difference is that tokens will expire in the future and your password can only be changed manually. This is a security advantage when using a token compared to using your password directly.

Requesting a Token

Tokens work just like a password so they should be stored securely. Access tokens may expire at any time in the future.

Request URL:

https://my.maplarge.com/auth/login?mluser=email@your.com&mlpass=your_password
Note: To protect your password, always use https in this request.

Successful Response

{
    "success": true,
    "user": "root_user@ml.com",
    "token": "-306453411_1435368558",
    "errors": null
}

Unsuccessful Response

{
    "success": false,
    "user": null,
    "token": null,
    "errors": [
        "The password is incorrect for this user."
    ]
}

Example GET Requests

GET using Token

https://my.maplarge.com//Remote/CreateTableSynchronous?
&account=test
&tablename=testtableA5345
&fileurl=http://domaingoeshere.net/census_states.csv
&mltoken=your_token
&mluser=your_username

GET using Password:

https://my.maplarge.com//Remote/CreateTableSynchronous?
&account=test
&tablename=testtableA5345
&fileurl=http://domaingoeshere.net/census_states.csv
&mluser=email@your.com
&mlpass=your_password

Example POST Requests

The only time a POST request is required is during file uploads. The web services API expects the POST to be in the same format as a browser file upload. Here are some code examples to get you started.

File Upload

  1. string url = "https://my.maplarge.com/Remote/CreateTableWithFilesSynchronous?mltoken=token&mluser=your_username&account=test&tablename=test123";
  2. string filePath = @"E:\Maplarge\myfile.csv";
  3. WebClient wc = new WebClient();
  4. byte[] responseArray = wc.UploadFile(url, filePath);
  1. import org.apache.http.HttpEntity;
  2. import org.apache.http.HttpResponse;
  3. import org.apache.http.client.ClientProtocolException;
  4. import org.apache.http.client.methods.HttpPost;
  5. import org.apache.http.entity.mime.MultipartEntityBuilder;
  6. import org.apache.http.entity.mime.content.FileBody;
  7. import org.apache.http.impl.client.CloseableHttpClient;
  8. import org.apache.http.impl.client.HttpClients;
  9. import org.apache.http.util.EntityUtils;
  10.  
  11. import java.io.*;
  12.  
  13.  
  14. public class PostExample {
  15.  
  16. public static void main(String[] args) {
  17. //This example uses Apache HttpClient. http://hc.apache.org/
  18. MultipartEntityBuilder builder = MultipartEntityBuilder.create();
  19. builder.addPart("file", new FileBody(new File("E:\\Maplarge\\geotest.js")));
  20.  
  21. HttpEntity entity = builder.build();
  22.  
  23. HttpPost request = new HttpPost("http://my.maplarge.com/Remote/CreateTableWithFilesSynchronous?mltoken=your_token&mluser=your_username&account=your_account&tablename=test123");
  24. request.setEntity(entity);
  25.  
  26. CloseableHttpClient client = HttpClients.createDefault();
  27.  
  28. try {
  29. HttpResponse response = client.execute(request);
  30. System.out.println(response.toString());
  31. HttpEntity responseEntity = response.getEntity();
  32. String responseString = EntityUtils.toString(responseEntity, "UTF-8");
  33. System.out.println(responseString);
  34. } catch (ClientProtocolException e) {
  35. // TODO Auto-generated catch block
  36. e.printStackTrace();
  37. } catch (IOException e) {
  38. // TODO Auto-generated catch block
  39. e.printStackTrace();
  40. }
  41.  
  42. }
  43.  
  44. }
  1. url = 'https://my.maplarge.com/Remote/CreateTableWithFilesSynchronous?mltoken=token&mluser=your_username&account=test&tablename=test123'
  2. r = requests.post(url, files={'myfile.csv': open('myfile.csv', 'rb')})