anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

Hit rest API #220

Closed dhimananju closed 2 years ago

dhimananju commented 3 years ago

Can I hit the rest API URL using custom workflow code? Can I send the parameter in that as well?

AirTibu commented 3 years ago

Hi,

Check this:

https://www.redmine.org/projects/redmine/wiki/Rest_api_with_ruby

dhimananju commented 3 years ago

This needs to include some core files, how can I include them using custom workflow? Can same code work using custom workflow?

Thanks

Anju Dhiman

Sr. PHP Consultant

Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN)

Target Integration | CRM • ERP • Cloud

Website https://www.targetintegration.com/| LinkedIn https://www.linkedin.com/company/targetint | Twitter https://twitter.com/TargetInt| Facebook https://www.facebook.com/targetint/| Youtube https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ| Instagram https://www.instagram.com/targetint.official/

On Fri, Jun 4, 2021 at 8:31 AM AirTibu @.***> wrote:

Hi,

Check this:

https://www.redmine.org/projects/redmine/wiki/Rest_api_with_ruby

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anteo/redmine_custom_workflows/issues/220#issuecomment-854322326, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY6TXFYHSNXLOKKQKKSQJDTRA6X5ANCNFSM454ATCPA .

picman commented 3 years ago
cd redmine
gem install activeresource

You can also call curl as described here.

dhimananju commented 3 years ago

How to write this code in workflow? See attached screenshot where I want to write code.

Thanks

Anju Dhiman

Sr. PHP Consultant

Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN)

Target Integration | CRM • ERP • Cloud

Website https://www.targetintegration.com/| LinkedIn https://www.linkedin.com/company/targetint | Twitter https://twitter.com/TargetInt| Facebook https://www.facebook.com/targetint/| Youtube https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ| Instagram https://www.instagram.com/targetint.official/

On Fri, Jun 4, 2021 at 11:02 AM Karel Picman @.***> wrote:

cd redmine gem install activeresource

You can also call curl as described here https://www.redmine.org/projects/redmine/wiki/Rest_api_with_curl.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anteo/redmine_custom_workflows/issues/220#issuecomment-854370827, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY6TXEHA7SC6VYKKG6OPBLTRBQONANCNFSM454ATCPA .

AirTibu commented 3 years ago

How to write this code in workflow? See attached screenshot where I want to write code. Thanks Anju Dhiman Sr. PHP Consultant Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN) Target Integration | CRM • ERP • Cloud Website <https://www.targetintegration.com/>| LinkedIn https://www.linkedin.com/company/targetint | Twitter <https://twitter.com/TargetInt>| Facebook <https://www.facebook.com/targetint/>| Youtube <https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ>| Instagram https://www.instagram.com/targetint.official/ On Fri, Jun 4, 2021 at 11:02 AM Karel Picman @.***> wrote: cd redmine gem install activeresource You can also call curl as described here https://www.redmine.org/projects/redmine/wiki/Rest_api_with_curl. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#220 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY6TXEHA7SC6VYKKG6OPBLTRBQONANCNFSM454ATCPA .

Where is the attachment?

dhimananju commented 3 years ago

Attaching now the screenshot, I want to write code in saving the observable object.

Thanks

Anju Dhiman

Sr. PHP Consultant

Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN)

Target Integration | CRM • ERP • Cloud

Website https://www.targetintegration.com/| LinkedIn https://www.linkedin.com/company/targetint | Twitter https://twitter.com/TargetInt| Facebook https://www.facebook.com/targetint/| Youtube https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ| Instagram https://www.instagram.com/targetint.official/

On Wed, Jul 28, 2021 at 12:13 PM AirTibu @.***> wrote:

How to write this code in workflow? See attached screenshot where I want to write code. Thanks Anju Dhiman Sr. PHP Consultant Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN) Target Integration | CRM • ERP • Cloud Website https://www.targetintegration.com/| LinkedIn https://www.linkedin.com/company/targetint | Twitter < https://twitter.com/TargetInt>| Facebook < https://www.facebook.com/targetint/>| Youtube < https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ>| Instagram https://www.instagram.com/targetint.official/ … <#m-2384521792888634317> On Fri, Jun 4, 2021 at 11:02 AM Karel Picman @.***> wrote: cd redmine gem install activeresource You can also call curl as described here https://www.redmine.org/projects/redmine/wiki/Rest_api_with_curl. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#220 (comment) https://github.com/anteo/redmine_custom_workflows/issues/220#issuecomment-854370827>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY6TXEHA7SC6VYKKG6OPBLTRBQONANCNFSM454ATCPA .

Where is the attachment?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anteo/redmine_custom_workflows/issues/220#issuecomment-888054788, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY6TXDFQLGMOFAY5N57OQ3TZ6RIDANCNFSM454ATCPA .

dhimananju commented 3 years ago

Hi,

Any update on this?

Thanks

Anju Dhiman

Sr. Software Developer

Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN)

Target Integration | CRM • ERP • Cloud

Website https://www.targetintegration.com/| LinkedIn https://www.linkedin.com/company/targetint | Twitter https://twitter.com/TargetInt| Facebook https://www.facebook.com/targetint/| Youtube https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ| Instagram https://www.instagram.com/targetint.official/

On Wed, Jul 28, 2021 at 12:16 PM Anju Dhiman < @.***> wrote:

Attaching now the screenshot, I want to write code in saving the observable object.

Thanks

Anju Dhiman

Sr. PHP Consultant

Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN)

Target Integration | CRM • ERP • Cloud

Website https://www.targetintegration.com/| LinkedIn https://www.linkedin.com/company/targetint | Twitter https://twitter.com/TargetInt| Facebook https://www.facebook.com/targetint/| Youtube https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ| Instagram https://www.instagram.com/targetint.official/

On Wed, Jul 28, 2021 at 12:13 PM AirTibu @.***> wrote:

How to write this code in workflow? See attached screenshot where I want to write code. Thanks Anju Dhiman Sr. PHP Consultant Tel: +353 1 886 5684 (IE) +44 121 285 5684 (UK) +91 124 634 5684 (IN) Target Integration | CRM • ERP • Cloud Website https://www.targetintegration.com/| LinkedIn https://www.linkedin.com/company/targetint | Twitter < https://twitter.com/TargetInt>| Facebook < https://www.facebook.com/targetint/>| Youtube < https://www.youtube.com/channel/UCbYMFVDmcAOIkF8IAWOrAVQ>| Instagram https://www.instagram.com/targetint.official/ … <#m_6480580732418893927m-2384521792888634317_> On Fri, Jun 4, 2021 at 11:02 AM Karel Picman @.***> wrote: cd redmine gem install activeresource You can also call curl as described here https://www.redmine.org/projects/redmine/wiki/Rest_api_with_curl. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#220 (comment) https://github.com/anteo/redmine_custom_workflows/issues/220#issuecomment-854370827>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY6TXEHA7SC6VYKKG6OPBLTRBQONANCNFSM454ATCPA .

Where is the attachment?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anteo/redmine_custom_workflows/issues/220#issuecomment-888054788, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY6TXDFQLGMOFAY5N57OQ3TZ6RIDANCNFSM454ATCPA .

kiscsiri commented 3 years ago

Hi @dhimananju!

If you or anybody still looking for an example workflow, I show you my working solution.

This example calls a .NET Core API, if there is a new non-private note on the issue.

Before script:

@is_private = @issue.current_journal&.private_notes?
@new_note = @issue.current_journal&.notes?

After script:

require 'uri'
require 'net/http'
require 'json'

if @new_note && !@is_private
 uri = URI.parse('http://{endpoint-url}')
 res = Net::HTTP.post_form(uri, 'param1' => value1, 'param2' => value2)
end

With this example, you can POST data as parameters, I think, this works with json parser too,

If you need HTTPS, but you trust your local network(eg. corporate private network), you can do something like this, in the before script:

require 'uri'
require 'net/http'
require 'json'

if @issue.current_journal&.notes? &&  !@issue.current_journal&.private_notes?
    uri = URI.parse("https://{your-endpoint}")
    https = Net::HTTP.new(uri.host, 443)
    https.use_ssl = true
    https.verify_mode = OpenSSL::SSL::VERIFY_NONE
    req = Net::HTTP::Post.new(uri.path)
    req.set_form_data('param1' => value1, 'param2' => value2)
    res = https.request(req)
end

Hope this helps