You are not logged in.

#1 2018-04-26 06:35:40

Reen
Member
Registered: 2018-04-26
Posts: 2

/plate/add API requests return 200 response but not adding plate

I am trying to add plate via API call through Python code. I start Nano dlp server and load file  like
data={some data}
files = {'ZipFile': (filename,  open(filePath, 'rb'))}
result = requests.post("http://127.0.0.1:8080/plate/add", files=files, data=data, timeout=100)

it return <Response [200]> but plate is not added.
I can't figure out the issue.

Anyone please help me. Even in same way I write code to get list of plates. but result same response code 200 but how I can get data

Offline

#2 2018-04-29 12:45:21

ToS
Member
Registered: 2017-09-18
Posts: 24

Re: /plate/add API requests return 200 response but not adding plate

Well, I have neither knowldge nor experiece with python. By incident I implemented such a request successfully with javascript a couple of days ago.
From the looking on your code, I wonder about the lines...

data={some data}
files = {'ZipFile': (filename,  open(filePath, 'rb'))}

I wouldn't expected the "open" expression to be located the "files =..." line. But thats maybe some python related thing I don't understand.

Following is the javascript code I wrote (it's tested and works fine):

        var fs = require("fs");
        var buffer = fs.readFileSync( path + "/" + file);
  
        let result = request( {
	   uri: global.SERVER_URL + "/plate/add",
	   formData: {
              'ZipFile': {
                 value: buffer,
                 options: {
                    filename: file
                 }
              },
              'Path': file,
              'ProfileID': prid
	   },
	   method: 'POST'
	 });

variables...
buffer -> will be filled by fs.readFileSync() with the content of the STL-file
path -> path of the STL-file, excluding the filename
file -> filename of the STL-file, excluding the path
prid -> integer for the profile-id

Offline

#3 2018-05-04 15:15:00

Reen
Member
Registered: 2018-04-26
Posts: 2

Re: /plate/add API requests return 200 response but not adding plate

Thanks. It was sorted. Issue was in data set.

Offline

Board footer

Powered by FluxBB