Hey,

I am using the following script in my CPF application, on insert. It worked 
fine when it was just adding the extra <insert_timestamp /> node, as well as 
the searchable collection, however I’m trying to make a HTTP GET call and check 
the response via logging but it throws an error:

<error:code>XDMP-UNDVAR</error:code>
      <error:name>err:XPST0008</error:name>
      <error:xquery-version>1.0-ml</error:xquery-version>
      <error:message>Undefined variable</error:message>
      <error:format-string>XDMP-UNDVAR: (err:XPST0008) Undefined variable 
$serverResponse</error:format-string>
      <error:retryable>false</error:retryable>
      <error:expr> </error:expr>
      <error:data>

My code is:

xquery version "1.0-ml";
import module namespace cpf="http://marklogic.com/cpf";
  at "/MarkLogic/cpf/cpf.xqy";
declare variable $cpf:document-uri as xs:string external;
declare variable $cpf:transition as node() external;
if (cpf:check-transition($cpf:document-uri,$cpf:transition)) then try {
  let $doc := fn:doc($cpf:document-uri)

  let $serverResponse := xdmp:http-get("my-url")
     (: <options xmlns="xdmp:http">
       <authentication method="basic">
         <username>myname</username>
         <password>mypassword</password>
       </authentication>
       <data>{$cpf:document-uri}</data>
       <headers>
         <content-type>text/plain</content-type>
       </headers>
     </options>) :)

return xdmp:node-insert-child($doc/root, 
<insert_timestamp>{fn:current-dateTime()}</insert_timestamp>),
  xdmp:document-add-collections($cpf:document-uri, ("searchable")),
  xdmp:log(fn:concat('VARABLE: ', $serverResponse)),
  cpf:success($cpf:document-uri, $cpf:transition, ())
} catch ($e) {
  cpf:failure($cpf:document-uri, $cpf:transition, $e, ())
}
else ()

Does anyone know why the this isn’t working?

As an FYI, I can make a curl call to the URL fine from the command line and it 
returns what I expect. If I remove the xmdp:log() call, it also processes fine… 
I just have no way of seeing the output though.

Thanks,

Ashley



[cid:[email protected]]


[cid:[email protected]]


Ashley Peacock


Developer II
Elevate Credit International Limited
P: 01284 717800 | Ext: 877 |  Elevate.co.uk<http://elevate.co.uk>
Amadeus House, Floral Street, Covent Garden, London WC2E 9DP




Privileged and Confidential. This e-mail, and any attachments thereto, is 
intended only for use by the addressee(s) named herein and may contain 
privileged and/or confidential information. If you have received this e-mail in 
error, please notify me immediately by a return e-mail and delete this e-mail. 
You are hereby notified that any dissemination, distribution or copying of this 
e-mail and/or any attachments thereto, is strictly prohibited.

Elevate Credit International Limited is registered in England & Wales with 
Company Number 05041905. Registered Office: 27-28 Eastcastle Street, London, 
W1W 8DH


_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to