This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

mfws and python

Former Member
Former Member
I'm currently starting a project to interact with mfiles using python.  I've managed to get authentication tokens with this code:

#testbed for requests (http api) and mfiles REST interface
import requests
import json
#try to retrieve authentication tokens
authentication = 'localhost/.../authenticationtokens.aspx'
data = json.dumps({"Username":"yourname", "Password":"yourpassword"})
h= requests.post(authentication, data = data)
print(h.reason,'reason')
print('#')
print(h._content)

Anyone interested in working on this jointly?

New discovery.  The data line must be changed to :

data = json.dumps({"Username":"yourname", "Password":"yourpassword",
                  "VaultGuid":"{1E5F2435-AFB8-4A7D-92D3-45B04D1268D9}"})

or the token won't work for individual vault access.

Parents
  • Former Member
    Former Member
    New update on the project. The following code will check out an object. I am assuming that you have received an authentication token as in the previous posts.

    url = ''.join((baseurl,'/objects/184/54/checkedout.aspx?_method=PUT'))
    somedata = json.dumps({'Value':2})
    headers = {"content-type":"application/json", 'X-Authentication':authtoken}
    query = requests.post(url, headers=headers, data = somedata)

    Changing the Value to 0 checks the object back in. If you check it out in python you can't check it in from the m-files client without forcing a check in.


    The big problem I'm having is trying to modify a property. Let's say I am trying to use the resource '/objects/(type)/(objectid)/(version)/properties/(id). In my particular installation, '/objects/184/54/1235'. I can use GET and not have a problem, but when I try to put I receiver server codes 500 or 405 depending on the code that I am trying.

    If I was going to modify this string property to say, "mfiles is great", what should the code look like in javascript? I can't find a good example of modifying a single property in the documentation.




Reply
  • Former Member
    Former Member
    New update on the project. The following code will check out an object. I am assuming that you have received an authentication token as in the previous posts.

    url = ''.join((baseurl,'/objects/184/54/checkedout.aspx?_method=PUT'))
    somedata = json.dumps({'Value':2})
    headers = {"content-type":"application/json", 'X-Authentication':authtoken}
    query = requests.post(url, headers=headers, data = somedata)

    Changing the Value to 0 checks the object back in. If you check it out in python you can't check it in from the m-files client without forcing a check in.


    The big problem I'm having is trying to modify a property. Let's say I am trying to use the resource '/objects/(type)/(objectid)/(version)/properties/(id). In my particular installation, '/objects/184/54/1235'. I can use GET and not have a problem, but when I try to put I receiver server codes 500 or 405 depending on the code that I am trying.

    If I was going to modify this string property to say, "mfiles is great", what should the code look like in javascript? I can't find a good example of modifying a single property in the documentation.




Children
No Data