Error while creating module with amster

Tagged: ,

This topic has 4 replies, 2 voices, and was last updated 4 days, 7 hours ago by abarry.

  • Author
    Posts
  • #27353
     abarry
    Participant

    Hello,

    I’m using amster to create a scripted module but I got this error :

    [main] ERROR org.forgerock.amster.org.forgerock.openam.sdk.http.DefaultErrorHandler - Unhandled client error: [Status: 400 Bad Request]
    Failed to execute the 'create' command. 400 Bad Request: The request could not be processed because it did not contain any JSON content

    Here my command :
    create ScriptedModule --realm employee --id test2FA--body '{"clientScriptEnabled":false,"serverScript":"script_test2FA","authenticationLevel":1}'

    Don’t really get what the problem with the json in the body. I even tried to execute the example request give in amster help tool but got the same error.

    create DataStoreModule --realm / --body '{"_id":"myDataStore"}'
    [main] ERROR org.forgerock.amster.org.forgerock.openam.sdk.http.DefaultErrorHandler - Unhandled client error: [Status: 400 Bad Request]
    Failed to execute the 'create' command. 400 Bad Request: The request could not be processed because it did not contain any JSON content

    Can someone help ?

    Regards,

    #27355
     Kumar
    Participant

    1. Ensure there is no issue with server side script(i.e script_test2FA)
    2. Get the corresponding unique id for the server side script. This can be obtained from AM Console or via amster utility.
    Unique id will be something like this – 7980826c-681c-434f-b06e-966517b33a2e

    3. Once obtained the unique value, use the appropriate value to run the following command to create required scripted module
    e.g

    create ScriptedModule –realm /employee –body ‘{ “_id”: “test2FA”, “clientScriptEnabled”: false, “serverScript”: “7980826c-681c-434f-b06e-966517b33a2e”, “authenticationLevel”: 1 }’

    #27356
     abarry
    Participant

    Thank you Kumar for your help but still got the same error :

    create ScriptedModule --realm /employee --body '{"_id": "test2FA", "clientScriptEnabled": false, "serverScript": "79eada46-0fae-4c61-ac83-07d5b1f60697", "authenticationLevel": 0}'
    [main] ERROR org.forgerock.amster.org.forgerock.openam.sdk.http.DefaultErrorHandler - Unhandled client error: [Status: 400 Bad Request]
    Failed to execute the 'create' command. 400 Bad Request: The request could not be processed because it did not contain any JSON content

    When I validate my server script via AM console I got the message “No errors found”.

    Regards,

    #27357
     Kumar
    Participant

    Were you able to read any existing module via amster utility? You probably try to run existing module to make sure you get out puts and there is no issue with amster utility.

    Just tried on my local setup and its working….

    amster localhost:8080> create ScriptedModule –realm /myPoc –body ‘{ “_id”: “myScriptModule2”, “clientScriptEnabled”: false, “serverScript”: “7980826c-681c-434f-b06e-966517b33a2e”, “authenticationLevel”: 1 }’
    ===> {
    “clientScriptEnabled”: false,
    “clientScript”: “[Empty]”,
    “serverScript”: “7980826c-681c-434f-b06e-966517b33a2e”,
    “authenticationLevel”: 1,
    “_rev”: “1653548328”,
    “_type”: {
    “_id”: “scripted”,
    “name”: “Scripted Module”,
    “collection”: true
    },
    “_id”: “myScriptModule2”
    }
    amster localhost:8080>

    #27365
     abarry
    Participant

    Thank you Kumar for your help but still struggling with this error. I tried to run amster in debug mode. Here the request :
    create ScriptedModule --realm /employee --id test2FA--body '{"clientScriptEnabled":false,"serverScript":"79eada46-0fae-4c61-ac83-07d5b1f60544","authenticationLevel":1}'

    and I got this output :

    [main] DEBUG org.forgerock.sdk.org.apache.http.impl.execchain.MainClientExec - Executing request PUT /connexion/json/realms/root/realms/employee/realm-config/authentication/modules/scripted/test2FA HTTP/1.1
    [main] DEBUG org.forgerock.sdk.org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
    [main] DEBUG org.forgerock.sdk.org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> PUT /connexion/json/realms/root/realms/employee/realm-config/authentication/modules/scripted/test2FA HTTP/1.1
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> Content-Length: 0
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> Accept-API-Version: protocol=2.1,resource=1.0
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> Content-Type: application/json; charset=UTF-8
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> If-None-Match: *
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> Host: localhost:30001
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> Connection: Keep-Alive
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> User-Agent: Apache-HttpClient/4.5.6 (Java/1.8.0_131)
    [main] DEBUG org.forgerock.sdk.org.apache.http.headers - http-outgoing-1 >> Accept-Encoding: gzip,deflate
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "PUT /connexion/json/realms/root/realms/employee/realm-config/authentication/modules/scripted/test2FA HTTP/1.1[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "Content-Length: 0[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "Accept-API-Version: protocol=2.1,resource=1.0[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "If-None-Match: *[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "Host: localhost:30001[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "User-Agent: Apache-HttpClient/4.5.6 (Java/1.8.0_131)[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "Accept-Encoding: gzip,deflate[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 >> "[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "HTTP/1.1 400 Bad Request[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "X-Frame-Options: SAMEORIGIN[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "Cache-Control: no-cache[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "X-Content-Type-Options: nosniff[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "Content-Type: application/json;charset=UTF-8[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "Content-Length: 126[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "Date: Tue, 14 Jan 2020 10:46:08 GMT[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "Connection: close[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "[\r][\n]"
    [main] DEBUG org.forgerock.sdk.org.apache.http.wire - http-outgoing-1 << "{"code":400,"reason":"Bad Request","message":"The request could not be processed because it did not contain any JSON content"}"

    I can see that the http request sent to OpenAM didn’t contain the body I specified in the amster request. Maybe the problem came from here but don’t know why there isn’t the body.

    Regards,

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

©2020 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?