Hello Hans -

POST services will need to have data in the HTTP Body. So, any OFBiz
service (irrespective of engine), that is exposed as POST, you will need to
pass the JSON data in POST body. Here is the corresponding cURL for the
service in question -

curl -X  POST https://localhost:8443/rest/services/ensureNaPartyRole -d
'{"partyId":"admin"}' -H "Content-Type: application/json" -H "Accept:
application/json" -H "Authorization: Bearer $token" --insecure

Please note the use of the "-d" argument. You can also use '--data' instead
of '-d'. It sets the data in the request body.

I am not sure if you have taken a look at the OpenAPI documentation. You
can follow https://localhost:8443/docs/swagger-ui.html and it will show all
endpoints available along with example usage.

All in all, GET endpoint needs service IN attributes specified in a JSON
string wrapped in "inParams" query parameter, while POST endpoint needs
service IN attributes be part of HTTP body in JSON.

Best,
Girish





On Mon, Sep 7, 2020 at 2:58 PM Hans Bakker <h.bak...@antwebsystems.com>
wrote:

> Hi Girish,
>
> thanks for your last help, that worked fine.
>
> I am struggling with simple method services.
>
> i went to applications/party/servicedef/services.xml
>
> and enabled the service ensureNaPartyRole with export="true" and
> action="post"
>
> then issued the command:
>
> curl -G -X  POST https://localhost:8443/rest/services/ensureNaPartyRole
> --data-urlencode 'inParams={"partyId":"admin"}' -H "Accept:
> application/json" -H "Authorization: Bearer $token" --insecure
>
> and tells me:
> {
>    "statusCode" : 500,
>    "statusDescription" : "Internal Server Error",
>    "errorMessage" : "Required Field Missing : Party Id"
> }
>
> any idea?
>
> Thanks in advance.
>
> Hans
>
>
> just a quick question , does it also work with minilang?
>
>
>   i get
> {
>    "statusCode" : 500,
>    "statusDescription" : "Internal Server Error"
> }:
> Regards.
>
> On 9/5/20 8:26 PM, Girish Vasmatkar wrote:
> > Hello Hans
> >
> > Thanks for giving it (REST Impl) a try and providing valuable
> feedback.The
> > token's signature part and the payload part (that includes claims) does
> > indeed change, while the header part is not expected to change.
> > The token is revoked after it is expired (default is 1800 seconds basedon
> > security.properties).
> >
> > Looking forward to hearing more from you and please let us know of any
> > issue you encounter.
> >
> > Best Regards,
> > Girish
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Sep 5, 2020 at 6:51 AM Hans Bakker <h.bak...@antwebsystems.com>
> > wrote:
> >
> >> Good day!
> >>
> >> Good to see we finally have a REST interface in OFBiz, thank you
> >> girishvasmatkar for this implementation!
> >>
> >>     I will try to use it for the Growerp.org open source project, a
> >> flutter frontend for currently Moqui.org but also will try to use OFBiz,
> >> yes with this REST interface.
> >>
> >> My experience after away from ofbiz for a couple of years and just for
> >> other users getting started email.
> >>
> >> OFBIZ install:
> >> ==========
> >> i looked how to install ofbiz in the readme.adoc fle , this tells me to
> >> run ./gradle/init-gradle-wrapper for linux
> >> did not worked on my linux system, however ./gradlew init-gradle-wrapper
> >> worked but got stuck at the end...
> >> killed it and then ran ./gradlew cleanAll loadAll and all was fine.
> >>
> >> Did not know how to install a plugin, ( a lot changed the last couple of
> >> years that is good!) so i added it to the application folder and updated
> >> the component-load.xml file. that was still the same.
> >>
> >> REST plugin:
> >> ==========
> >> then I searched for how to get an token after authorization.
> >> These curl commands worked for me: could be added to the READ me file?
> >>
> >> curl -X POST https://localhost:8443/rest/auth/token -H "Accept:
> >> application/json" -u admin:ofbiz --insecure
> >>
> >> however when i requested it the second time, the token did not change?
> >> shouldn't it? Now i cannot revoke a token?
> >>
> >> then tried the services list:
> >> curl -X GET https://localhost:8443/rest/services -H "Accept:
> >> application/json" -H "Authorization: Bearer
> >>
> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJBcGFjaGVPRkJpeiIsImlhdCI6MTU0NzczOTM0OCwiZXhwIjoxNjc5Mjc1MzQ4LCJhdWQiOiJ3d3cuZXhhbXBsZS5jb20iLCJzdWIiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiR2l2ZW5OYW1lIjoiSm9obm55IiwiU3VybmFtZSI6IlJvY2tldCIsIkVtYWlsIjoianJvY2tldEBleGFtcGxlLmNvbSIsInVzZXJMb2dpbklkIjoiYWRtaW4iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.fwafgrgpodBJcXxNTQdZknKeWKb3sDOsQrcR2vcRw97FznD6mkE79p10Tu7cqpUx7LiXuROUAnXEgqDice-BSg"
> >>
> >> --insecure
> >>
> >> also working fine!
> >>
> >> if I have more comments or remarks, i will let you know
> >>
> >> Regards,
> >>
> >> Hans Bakker https://www.AntWebsystems.com
> >> we specialize in flutter.dev growerp.org moqui.org and ofbiz.apache.org
> >>
> >>
> >>
>

Reply via email to