Expand my Community achievements bar.

Using Classifications API to upload file automatically

Avatar

Level 4

Premise: I am creating a process where a maintained classifications file can be fully or partially manually be uploaded to Analytics' Classifications API and data is updated. This can be done with relative ease using FTP file transfer to send items in, but since the API has more options, we decided to investigate would it cover our needs. Even though the Classifications Datasets are a bit more hassle to explain and especially to get them programmatically with indications which one to use, I've managed to build the flow nicely and can run everything in Postman Flows. Almost everything that is.

There was another post (I will add a link when I find it) that was trying to do something similar and ran into this issue as well. Sending the upload lead to this error message:

{
    "errorCode": "500",
    "errorDescription": "Cannot invoke \"javax.servlet.http.Part.getInputStream()\" because \"filePart\" is null",
    "errorId": "abcd1234"
}

What this means is that the receiving Java servlet cannot find the file uploaded to process. This is likely because the documentation does not say where that file is supposed to be attached, as we can see here: Import API classifications by uploading files, more specifically this part:

SSampsa_0-1732785726402.png

This defines the name of the file and where that file is located on the sending device. All good, but that doesn't actually mean the file is attached to the request in cURL, nor will cURL try to read it based on these values. I have tried to replace the "Value" with cURL's upload syntax, added a new field and so on, but since I don't know the name of the field, the file never gets processed. In another post I read comments related to the file not being accessible, which should not be the case, but to be sure I ran the same code in cURL locally in Windows directly, as well as a separate Unix server, all with the same results.

 

To put this shortly: Does anyone know what is the filename Classifications API file upload is expecting, so I could successfully send a file to it, OR alternatively: Am I doing this wrong and the API example should work as defined?

 

5 Replies

Avatar

Level 4

In relation to the question I referred, one of the replies referred to file uploads to cloud destinations (Locations) and file locations. This, I think, is the issue: I consider file uploads to be actual uploads, but in reality they are likely ways to tell Classifications API in which cloud location the file is and to download it from there, rather than actually being a file upload. In my opinion this naming is a bit misleading and the documentation does not refer to locations in any way. I will test this out and see if this solves my issue.

Avatar

Community Advisor and Adobe Champion

Please let us know what you find!

 

I was in that previous discussion, and I have not used this... but my guess is that the file location needs an absolute location (https://www.domain.com/folder/location/file.tsv), as opposed to a relative location (/folder/location/file.tsv).... unless this script is being run from a web server, and the file is on the same server where the relative link can be accessed, I don't see how Adobe could possibly find the file based on the limited information.. and if running the API locally (i.e. using Postman), files located on your hard drive are not accessible to the web.  

 

 

Good luck testing.

Avatar

Level 4

Indeed and thanks for chipping in. The documentation refers as the only example to a local filepath, but this could be a local filepath in any system. I assumed it is local, but that is not how it works with cURL, so I will be adding a file location today and testing how it would work with e.g. SFTP.

If this is the case, I'm wondering how we separate between different location accounts as an example, since the documentation only shows file name and full path including file name, but lets assume I have two different SFTP servers I use, so how are the location specifics passed on? With SFTP (which is FTP wrapped in SSH) you can do this as a part of the URL, but how about Azure or Amazon locations? I can only guess.

Avatar

Community Advisor and Adobe Champion

Agreed, the documentation is a bit lacking in those regards.... 

Avatar

Level 4

To update a little on this: You actually cannot use legacy methods such as SFTP with Classification Sets, so I created an Azure location and will proceed to see how I can use that. But since Classifications allow the use of automation and the API requires a set ID, which is not available except for lookups (correct me if I misunderstood this), I think the API provides very little value with the upload method. If I was to pass the data on directly as JSON, then it would be better, but the case here is to tackle an issue where the file would need to be very simple to maintain and update, which I am willing to bet JSON is not for those who never open code editors.

I plan to complete my test of this process during December and see if file upload to Azure + automation on UI works the way I expect it to, or if I could use API directly for all classification sets instead of just lookups. This pretty much defines what is the optimal path to make sure automation is not more work than running this process manually for the next two years