[WX22] WebDev - restResponse - I give up March 10, 2021 09:04PM |
Registered: 5 years ago Posts: 48 |
Re: [WX22] WebDev - restResponse - I give up March 12, 2021 10:15AM |
Registered: 3 years ago Posts: 107 |
FUNCTION JDEMOFileGetList(pErrLst is soErrorList, pMOStructure is string, pMOKey is string, pIncludeData is boolean = True, pServiceURL is string="v2/file/list", ...) pToken is string = :AISToken, pUserName is string = :JDEUserName, pUserPassword is string = :JDEUserPassword)boolean,JSON,oJDEMediaObjectList) //POST Doc: [docs.oracle.com] //Local variables Success is boolean = False ErrMsg is soErrorMessage RESTRqst is restRequest RESTResp is restResponse JSONRqst is JSON <description="v2.file.list"> JSONResp is JSON <description="resp.v2.file.list"> JSONError is JSON <description="resp.vx.orchestrator.service-error"> WHEN EXCEPTION IN //Build JSON Request JSONRqst.token = pToken JSONRqst.moStructure = pMOStructure JSONRqst.moKey = pMOKey JSONRqst.includeData = pIncludeData JSONRqst.thumbnailSize = 80 JSONRqst.formName = "" JSONRqst.version = "" //Set REST Request Parameters RESTRqst..UserAgent = "Pixontri JDEdwards REST" RESTRqst..ContentType = "application/json" RESTRqst..Content = JSONRqst RESTRqst..Method = httpPost RESTRqst..URL = :JDEEndPointURL+["/"]+pServiceURL RESTRqst..User = pUserName RESTRqst..Password = pUserPassword //Clear current list WXJDEMediaObjectList.list.DeleteAll() //Execute REST request RESTResp = RESTSend(RESTRqst) //Server was reachable? IF NOT ErrorOccurred THEN //Evaluate REST response //Possible values for this request: // 200 Response Successful Execution // 400 Response Bad Request - Invalid JSON Input // 403 Response Authorization Failure // 405 Response Allowed Hosts on the HTML server is not configured to accept requests from this AIS Server // 415 Response Invalid Content-Type Header // 445 Response Mobile SSO Failed // 446 Response Mobile SSO Requested, but SSO is not Enabled on this AIS Server // 500 Response Server Failed to Process Request SWITCH RESTResp.StatusCode CASE 200: JSONResp = RESTResp.Content //Transfer to WX Media Object list too obj is JSON <description = "resp.v2.file.list.mediaObjects"> FOR EACH obj IN JSONResp.mediaObjects JDEMO is oJDEMediaObject JDEMO.moStructure = pMOStructure JDEMO.moKey = pMOKey JDEMO.moSequence = obj.sequence <... Do bunch of enrichment processing here on the retrieved media object and finaly add it into the return list...> Add(WXJDEMediaObjectList.list,JDEMO) END Success = True CASE 444,500: JSONError = RESTResp.Content ErrMsg:AddToList(pErrLst,soErrorMessage.EM_ERROR,"HTTP REST",JSONError.message..Value+" ["+JSONError.type..Value+"]","Exception: "+JSONError.exception..Value+CR+JSONError.userDefinedErrorText..Value) OTHER CASE: ErrMsg:AddToList(pErrLst,soErrorMessage.EM_ERROR,"HTTP REST","An error was encountered while trying to login to JDE.",RESTResp.StatusCode+": "+RESTResp.DescriptionStatusCode) END ELSE ErrMsg:AddToList(pErrLst,soErrorMessage.EM_ERROR,"HTTP REST","An error was encountered while trying to login to JDE.",ErrorInfo(errCode)+": "+ErrorInfo(errMessage)) END //Return Result RESULT (Success, JSONResp, WXJDEMediaObjectList) DO WXApplication::LogException(pErrLst) <COMPILE IF ConfigurationType<>Android> ExceptionEnable() <END> RESULT (False, Null, WXJDEMediaObjectList) END
Derek
Re: [WX22] WebDev - restResponse - I give up March 13, 2021 12:35AM |
Re: [WX22] WebDev - restResponse - I give up March 13, 2021 10:49AM |
Registered: 5 years ago Posts: 141 |
Re: [WX22] WebDev - restResponse - I give up April 17, 2021 09:49AM |
Registered: 5 years ago Posts: 29 |