FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious example

Making a request to DMP Manager

Description
Demonstrates making an HTTP POST request to DMP Manager.

dmp_commitsolution.zip[download all files]

Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
commitsolution.mos[download]





commitsolution.mos

(!*******************************************************
  * Mosel DMP Integration Examples                      *
  * ==============================                      *
  *                                                     *
  * file commitsolution.mos                             *
  * ```````````````````````                             *
  * Example of making a webservice request to DMP       *
  * Manager to 'commit' the solution.                   *
  *                                                     *
  * Note: this must be run within a cloud component     *
  * (Xpress Insight or Xpress Executor)                 *
  *                                                     *
  * (c) 2018 Fair Isaac Corporation                     *
  *     author: James Farmer, 2018                      *
  *******************************************************!)
model commitsolution
  uses 'dmp','mmsystem'
  
  declarations
    xecomp: dmpresource
    httpstatus: integer
    public REQUEST_BODY='{"label":"commitSolutionTest","comment":"dmp module example"}'
  end-declarations
  
  ! Initialize dmpresource
  dmpinitmanager(xecomp)
  if xecomp.status<>DMP_OK then
    writeln('ERROR finding DMP Manager: ',xecomp.lasterror)
    exit(1)
  end-if
  
  ! Make request
  httpstatus := dmphttppost(xecomp, '/rest/dmp/runtime/solutions/'+getdmpsolid+'/revisions?async=false', 
    'text:REQUEST_BODY', 'response.dat')
  if httpstatus<>200 then
    if xecomp.status<>DMP_OK then
      writeln('ERROR making DMP Manager request: ',xecomp.lasterror)
    else
      writeln('ERROR returned by DMP Manager request: ',httpstatus)
    end-if
    exit(1)
  end-if
  
  writeln('Committed new solution revision')
  
end-model

Back to examples browserPrevious example