Part II: Talking to SEVIS

Talking to SEVIS involved several steps:

SEVIS accepts certificate-encrypted HTTPS uploads of XML files and downloads of gzipped files. While there are definitely straightforward ways to achieve this functionality using .NET, Java, and/or Perl, the least complicated method is definitely with a mature, cross-platform and free command line utility like cURL.

By selecting cURL, we've reduced the problem to selecting the right command line switches.

I'm going to assume that you either have a sample XML file, or you've taken the one I've provided in references at the end of the article. If you're using my XML file, you'll need to make sure that all userid="" attributes, and that the batchid and schoolcode are accurate. For good measure, you should change the name and identifying characteristics of the student (SSN, license, name, remarks), because SEVIS is beginning to implement de-duping functionality and your batch might get kicked out if it looks too much like my sample.

Here's what the top part of the XML file looks like before modification:


Yours should look something like mine. Now, we invoke curl and pass in our pem file, give the pass-phrase we defined early, and then pass in the form variables:

It looks like this:



d:\Projects\sevis_batch\src>curl -E mycert.pem:"secretphrase" -F schoolcode=SEA214F00076000 -F batchid=00000000000003 -F xml=@20021104.xml https://egov2.ins.usdoj.gov/sevisbatchtest/action/batchUpload 

  % Total    % Received % Xferd  Average Speed          Time             Curr.

                                 Dload  Upload Total    Current  Left    Speed

100  5066  100   142  100  4924     33   1148  0:00:04  0:00:04  0:00:00     0

<?xml version="1.0" encoding="UTF-8"?>

<UPLOAD_RESULT batchID="00000000000003" dateTimeStamp="2002-11-04T18:35:13.687-05:00" accepted="true"/>

bash-2.05b$ 




The accepted="true" attribute is the key to knowing you have succeeded in sending the file.

I don't want to lead you to believe that the first time through this I was successful. Actually, I kept getting errors messages kicked back, and don't be surprised if you have the same issue. In my case, each of the error messages I received was clearly documented in the ICD Appendix B, as shown below.


After working through the error messages (typos in the schoolCode, not having the curl batchid match my XML file etc.) I still couldn't get it to work. It turns out I was given the wrong username to the SEVIS system, or rather there was a typo in the one I was given. A quick call to the SEVIS help desk cleared that up, and I was able to post successfully.

Now that SEVIS has your data, what are you supposed to do? Take a break. Really - it takes about an hour for batch files to be processed on the test servers, and until then you can't really do much. On the production servers, INS has indicated a turnaround of more like 1 day.

When the batch file is ready to download, invoke curl by passing in



bash-2.05b$ ./sevis_get20021104.bat 



d:\Projects\sevis_batch\src>curl -E mycert.pem:"secretphase" -o results/20021104.gz  -F schoolcode=SEA214F00076000 -F batchid=00000000000003 https://egov2.ins.usdoj.gov/sevisbatchtest/action/batchDownload 

  % Total    % Received % Xferd  Average Speed          Time             Curr.

                                 Dload  Upload Total    Current  Left    Speed

100  504k    0  504k  100   243  52482     24  0:00:09  0:00:09  0:00:00 84461




When we open up the file that came back to us, we see that we received a PDF file and an XML log of the transfer. Success!


Prev | Next