Hi Durai,

You need to prefix parameters with ‘rs:’. The prefix gets stripped off before 
being put in $params. It is to prevent name collisions with built-in REST api 
parameters.

Cheers

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of 
"[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Thursday, December 22, 2016 at 11:23 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Marklogic service extension - Post paramter

Hello team,

I am trying the below POST request and I have the post method coded as below. 
The $params map:map is received as blank in the function. I confirmed this from 
the log statement. Obviously there is a problem receiving the post parameters 
in the service extension. Am I missing something here?


http://localhost:8040/LATEST/resources/changePassword
POST

Content-type: application/x-www-form-urlencoded
Authorization: Basic [some value]

Form data:

User: some value
Password: some value

declare %rapi:transaction-mode("update")
function changePassword:post(
    $context as map:map,
    $params  as map:map,
    $input   as document-node()*
) as document-node()*
{

    let $output-types :=
        map:put($context,"output-types","application/xml")
    let $user := map:get($params, "user")
    let $password := map:get($params,"password")
    let $log := xdmp:log(("post...", $params,$context))
    let $content := <response>Done</response>
     return (document{$content}, xdmp:commit())
};


Thanks,
Durai.

This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to