Buddha
Buddha

Reputation: 4476

How to invoke a formhandler using ATG REST Client

I'm trying to invoke ProfileFormHandler's create handle using ATG rest client as shown below.

mSession = RestSession.createSession(mHost, mPort,"[email protected]","password");
mSession.setUseHttpsForLogin(false);
mSession.login();

Map<String,Object> params = new HashMap<String,Object>();
params.put("value.login", "[email protected]");
params.put("value.email", "[email protected]");
params.put("value.password", "password");

RestResult result = RestComponentHelper.executeMethod("/atg/userprofiling/ProfileFormHandler","create",null,params,mSession);

I'm getting form exceptions that says, I'm not passing Login and Password Fields.

["Missing value for the required property Password",
 "Missing value for the required property Login name"]

I've tried all combinations of login and password fields like value.login, Login, login, value.Login etc., but nothing seemed to work. All combinations giving the same form exceptions.

How do I invoke an ATG form handler using ATG REST Client and pass parameters to it?

Upvotes: 2

Views: 1264

Answers (2)

bated
bated

Reputation: 960

Definitely need more information but looking at your code I can see that you have a value.login which is not configured ootb and believe this is causing the NPE. Assuming you have not customized the ootb ATG RegistrationFormHandler and the required field in the repository the only values you need to pass to the form handler are:

  • value.email
  • value.password
  • value.confirmPassword
  • value.firstName
  • value.lastName

Also, the help is specific that the data-type of the value property needs to be java.util.Dictionary

Upvotes: 1

Sammy
Sammy

Reputation: 4578

Add the following to /atg/rest/security/restSecurityConfiguration.xml

<resource component="/atg/userprofiling/ProfileFormHandler" secure="false">
        <method name="handleCreate" secure="false">
          <acl value="EVERYONE:read,write,execute" />
        </method>
        <property name="value.login" secure="false" />
        <property name="value.password" secure="false" />
    </resource>

Upvotes: 0

Related Questions