Use java to access FreeNAS API

Status
Not open for further replies.

squeakyneb

Dabbler
Joined
Aug 3, 2014
Messages
10
I might be misreading something, and I've never programmed in Java (or am that familiar with FreeNAS) but I'm pretty sure I can mostly read it, BUT it seems like your examples aren't consistent.

Python is calling "/api/v1.0/storage/volume/", whereas Java is calling "/storage/volume/" but I don't see the "/api/v1.0" being prepended anywhere in the code.
 

ptan

Cadet
Joined
Jul 31, 2014
Messages
8
I might be misreading something, and I've never programmed in Java (or am that familiar with FreeNAS) but I'm pretty sure I can mostly read it, BUT it seems like your examples aren't consistent.

Python is calling "/api/v1.0/storage/volume/", whereas Java is calling "/storage/volume/" but I don't see the "/api/v1.0" being prepended anywhere in the code.

sorry, I did not make it clear that "preReqUri = "http://hostname/api/1.0/
 

squeakyneb

Dabbler
Joined
Aug 3, 2014
Messages
10
Huh. Can we get some wireshark dumps then? There's no reason that the same request should be treated differently just because the program was written in a different language. There has to be some different detail. Java and Python (and anything else, for that matter) are one and the same once they hit the network.
 

ptan

Cadet
Joined
Jul 31, 2014
Messages
8
Using java, I changed the user-agent field to python (It did not affact the result)

a1.png


Using java, results is like this:

a2.png
 

squeakyneb

Dabbler
Joined
Aug 3, 2014
Messages
10
Oh. The volume names are different. z123 and t123?

The authorization header also has different capitalisation but I'd be surprised if that causes problems.
 

ptan

Cadet
Joined
Jul 31, 2014
Messages
8
Volume name is specified by user, as far as I can see.

The strange thing is in the field of Authorization :
In python, it is translated as "credentials:" and the position is at the end of headers.
I don't know if it is the reason, and I cannot figure out how to change the sequence of several headers in Java.
 

squeakyneb

Dabbler
Joined
Aug 3, 2014
Messages
10
But don't you need a valid volume name? Or should freenas be returning a different error in that case?

Order of headers shouldn't be relevant in HTTP (unless multiple headers have the same name).
 
Status
Not open for further replies.
Top