1
0
-1

I installed the 7-BETA3.jar file , created an app with a simple form, added the Manage API key menu in the userview, created an api key for basic authentication, base64 encoded the admin:passwordhere string and did the following using python requests as well as in postman


import requests

url = 'http://appcenterint.xrxdev.ca/jw/api/form/smallGetData/addWithFiles'

payload = {'language''1',
'home_address''ca home',
'first_name''daniel.1',
'last_name''fung.1',
'dateModified''',
'dateCreated''',
'createdBy''',
'id''',
'modifiedBy''',
'createdByName''',
'modifiedByName'''}
files = {'your_photo'open('C:/Users/myusernamehere/Documents/small-doc-sample1.pdf','rb')}

proxies = {"http":None"https":None}

headers = {
  'api_id':'API-f255212a-2f0a-4b13-a453-7dc30a205b32'
  ,'api_key':'ce26291e29c743e09e2fb87cc87d2df3' 
  ,'Authorization':'*Basic YWRtaW46c21AbGxTcHJpbmc3MyE='
  ,'Content-Type''multipart/form-data'
  ,'accept':'application/json'}

# response = requests.request('POST', url, headers=headers, data=payload, files=files, proxies=proxies)
# response = requests.request('POST', url, headers=headers, data=payload, files=files, proxies=proxies)
response = requests.request('POST', url, headers=headers, proxies=proxies)

print(response.text.encode('utf8'))


I get the following error from the print above

'{"date":"Tue Nov 17 20:53:04 EST 2020","code":"401","message":"Authentication Failure"}'


i see the following in the Manage API Key Log

17-11-2020 09:07 PMAPI-f255212a-2f0a-4b13-a453-7dc30a205b32ce26291e29c743e09e2fb87cc87d2df3401form/smallGetData/addWithFilespython-requests/2.23.0192.168.122.217Authentication Failure365


in the APP's Logs I see the following


INFO 17 Nov 2020 20:19:43 org.joget.api.service.ApiBuilder - Authentication for user admin (10.11.6.55) : true
3839
ERROR 17 Nov 2020 20:19:43 org.joget.plugin.property.service.PropertyUtil - A JSONObject text must begin with '{' at character 0
3840
org.json.JSONException: A JSONObject text must begin with '{' at character 0
3841
    at org.json.JSONTokener.syntaxError(JSONTokener.java:496)
3842
    at org.json.JSONObject.<init>(JSONObject.java:180)
3843
    at org.json.JSONObject.<init>(JSONObject.java:403)
3844
    at org.joget.plugin.property.service.PropertyUtil.getPropertiesValueFromJson(PropertyUtil.java:140)
3845
    at org.joget.api.service.ApiBuilder.authenticate(ApiBuilder.java:893)
3846
    at org.joget.api.service.ApiBuilder.serveApi(ApiBuilder.java:711) ....


I tried this using POSTMAN, Visual Studio Code WIth Python Requests ( from 2 different servers) and all of them error out the same way.


I have API Domain and API IP whitelists both set to *


    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Here are my findings

      1 removing  ,"Content-Type":"multipart/form-data" from the headers collection makes the apikey approach work

      apikey with basic authentication with the User Permission Plugin does not work

      apikey with basic authentication with the "Logged In User" Permission Plugin works

       so 2 for 2, apikey/apiid and apikey/apiid/basic-auth (@ Logged In User) works

        CommentAdd your comment...
      1.  
        1
        0
        -1

        I just tried form data API to retrieve record and it worked on beta3 version of API Builder.


        Is it a specific API problem? Can you try other API to isolate the problem?

          CommentAdd your comment...