Data Manager Uploads.

4 posts / 0 new
Last post
dhagan
Data Manager Uploads.

I am looking for a way to automate data manager data uploads.  Has anyone ventured down that road?


MQBrianCoakley
Sure have. You can use the
Sure have. You can use the web service directly to automate any of the Data Manager functionality. The user interface is using the same service in the background.

ferdaus
requesting an example

can you give an example how to upload a csv file. 

api doc a bit confusing.

thanks.


MQBrianCoakley
There is a JavaScript example

There is a JavaScript example here. I use curl alot too.

 

curl --referer http://www.mapquest.com/x -F clientId=ID -F password=PW -F tableName=mqap.ID_name -F "file=@C:\Users\file.csv" "http://www.mapquestapi.com/datamanager/v2/upload-data?key=KEY&ambiguities=ignore"

 

Here is an old java method I haven't used in a long time.

 

public class DataManagerUpload {
    static String ci="id"; // clientId
    static String pw="pw"; // registry password
    static String tn="name"; // table name
    static String ak="key"; // application key
    static String bs="http://www.mapquestapi.com/"; // base server
    static String fu="datamanager/v2/upload-data"; // function
    static String dm=bs+fu+"?key="+ak+"&json=%7B%22clientId%22:%22"+ci+"%22,%22password%22:%22"+pw+"%22,%22tableName%22:%22mqap."+ci+"_"+tn+"%22%7D"; // data manager request url
    static String fs=File.pathSeparator;
    static String fn="C:\\path\\file.csv";
    public static void main(String[] args) throws Exception {
        HttpClient hc= new DefaultHttpClient();
        HttpPost hp=new HttpPost(dm);
        FileBody fb=new FileBody(new File(fn));
        MultipartEntity me=new MultipartEntity();
        me.addPart("file",fb);
        hp.setEntity(me);
        HttpResponse hr=hc.execute(hp);
        hr.getEntity();
    }
}