getting started with ofbiz-rest-impl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

getting started with ofbiz-rest-impl

Hans Bakker
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


grv
Reply | Threaded
Open this post in threaded view
|

Re: getting started with ofbiz-rest-impl

grv
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 based on
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 <[hidden email]>
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 | Threaded
Open this post in threaded view
|

Re: getting started with ofbiz-rest-impl

Hans Bakker
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 based on
> 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 <[hidden email]>
> 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 | Threaded
Open this post in threaded view
|

Re: getting started with ofbiz-rest-impl

Hans Bakker
In reply to this post by grv
OK, made some progress, have it now working from the flutter dart
environment however......

this curl works even from flutter dart,
curl -X  GET
https://localhost:8443/rest/services/findProductByI?inParams=%7B%22idToFind%22:%22GZ-1001%22%7D 
-H "Accept: application/json" -H "Authorization: Bearer $token" --insecure
however i do not want to url encode myself, so shouldn't this also work:

curl -X  GET https://localhost:8443/rest/services/findProductById 
--data-urlencode "{'inparams': {'idToFind':'GZ-1001'}}" -H "Accept:
application/json" -H "Authorization: Bearer $token" --insecure

I tried it also without the inner quotes but could not get his to work.....

i get:
{
   "statusCode" : 500,
   "statusDescription" : "Internal Server Error"
}

can you help?

regards,

Hans

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 based on
> 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 <[hidden email]>
> 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
>>
>>
>>
grv
Reply | Threaded
Open this post in threaded view
|

Re: getting started with ofbiz-rest-impl

grv
Hi Hans -

Here's that works (if you don't want to manually url encode) -

curl -G -X  GET https://localhost:8443/rest/services/findProductById
--data-urlencode
'inParams={"idToFind":"GZ-1001"}' -H "Accept: application/json" -H
"Authorization: Bearer $token" --insecure

Note '-G' parameter to CURL. It appends the encoded data to the URL.
Also, *--data-urlencode
*should contain key value pairs.

There has to have a query parameter named 'inParams' to call services
exposed as GET.
During it's implementation, I had given a thought whether to map each
service IN attribute as query parameter to the REST call, but I chose this
approach. A GET service with too many IN attributes would have resulted in
a large number of query parameters.

Best,
Girish


On Mon, Sep 7, 2020 at 9:59 AM Hans Bakker <[hidden email]>
wrote:

> OK, made some progress, have it now working from the flutter dart
> environment however......
>
> this curl works even from flutter dart,
> curl -X  GET
> https://localhost:8443/rest/services/findProductByI?inParams=%7B%22idToFind%22:%22GZ-1001%22%7D
> -H "Accept: application/json" -H "Authorization: Bearer $token" --insecure
> however i do not want to url encode myself, so shouldn't this also work:
>
> curl -X  GET https://localhost:8443/rest/services/findProductById
> --data-urlencode "{'inparams': {'idToFind':'GZ-1001'}}" -H "Accept:
> application/json" -H "Authorization: Bearer $token" --insecure
>
> I tried it also without the inner quotes but could not get his to work.....
>
> i get:
> {
>   "statusCode" : 500,
>   "statusDescription" : "Internal Server Error"
> }
>
> can you help?
>
> regards,
>
> Hans
> 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 based on
> 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 <[hidden email]> <[hidden email]>
> 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
>
>
>
grv
Reply | Threaded
Open this post in threaded view
|

Re: getting started with ofbiz-rest-impl

grv
That being said, I should make the query param mandatory such that it
returns 400 Bad Request "Missing Parameters" to let the client know of the
error.

I will make this improvement and commit soon.

Best,
Girish

On Mon, Sep 7, 2020 at 11:59 AM Girish Vasmatkar <
[hidden email]> wrote:

> Hi Hans -
>
> Here's that works (if you don't want to manually url encode) -
>
> curl -G -X  GET https://localhost:8443/rest/services/findProductById --data-urlencode
> 'inParams={"idToFind":"GZ-1001"}' -H "Accept: application/json" -H
> "Authorization: Bearer $token" --insecure
>
> Note '-G' parameter to CURL. It appends the encoded data to the URL. Also, *--data-urlencode
> *should contain key value pairs.
>
> There has to have a query parameter named 'inParams' to call services
> exposed as GET.
> During it's implementation, I had given a thought whether to map each
> service IN attribute as query parameter to the REST call, but I chose this
> approach. A GET service with too many IN attributes would have resulted in
> a large number of query parameters.
>
> Best,
> Girish
>
>
> On Mon, Sep 7, 2020 at 9:59 AM Hans Bakker <[hidden email]>
> wrote:
>
>> OK, made some progress, have it now working from the flutter dart
>> environment however......
>>
>> this curl works even from flutter dart,
>> curl -X  GET
>> https://localhost:8443/rest/services/findProductByI?inParams=%7B%22idToFind%22:%22GZ-1001%22%7D
>> -H "Accept: application/json" -H "Authorization: Bearer $token" --insecure
>> however i do not want to url encode myself, so shouldn't this also work:
>>
>> curl -X  GET https://localhost:8443/rest/services/findProductById
>> --data-urlencode "{'inparams': {'idToFind':'GZ-1001'}}" -H "Accept:
>> application/json" -H "Authorization: Bearer $token" --insecure
>>
>> I tried it also without the inner quotes but could not get his to
>> work.....
>>
>> i get:
>> {
>>   "statusCode" : 500,
>>   "statusDescription" : "Internal Server Error"
>> }
>>
>> can you help?
>>
>> regards,
>>
>> Hans
>> 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 based on
>> 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 <[hidden email]> <[hidden email]>
>> 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 | Threaded
Open this post in threaded view
|

Re: getting started with ofbiz-rest-impl

Hans Bakker
In reply to this post by grv
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 <[hidden email]>
> 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
>>
>>
>>
grv
Reply | Threaded
Open this post in threaded view
|

Re: getting started with ofbiz-rest-impl

grv
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 <[hidden email]>
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 <[hidden email]>
> > 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
> >>
> >>
> >>
>