Topic
  • 6 replies
  • Latest Post - ‏2013-07-13T17:10:58Z by atummidi
vinp
vinp
5 Posts

Pinned topic How to use REST API - setData?

‏2013-07-09T11:07:05Z |

Hi,

 

    I want to write a REST API setData in a general service to update a field in a Process Instance of a running BPD. Could you help me how can I do this using the url?

http://localhost:9080/rest/bpm/wle/v1/service/824?action=setData&params={"empDetails":{"mgrNotesID":"Dinesh Wadekar"}}

It would be great if you tell me how can I do this by running the above url using JavaScript or any other solution to do this.

Updated on 2013-07-09T13:05:22Z at 2013-07-09T13:05:22Z by vinp
  • andy.forget
    andy.forget
    3 Posts

    Re: How to use REST API - setData?

    ‏2013-07-09T19:21:27Z  

    You can't normally call a rest API from server side logic... You could, but you would have to make an HTTP call, probably through an HTTP integration. And even then, all REST calls are authenticated. This means that the HTTP call would need some basic auth information in it like user name and password. That alone might scare you away from doing this.

    Maybe, you should ask your question another way. For example:

    I need a way to change the data in a process instance from a server side script.

    It would be cool if this worked for you:

    tw.system.findProcessInstanceByID(tw.local.instance).businessData.put('first', tw.local.first);

    But, sadly, it does not. Unless someone comes up with a nice solution, this sounds like a great request for enhancement.

  • Vnn
    Vnn
    21 Posts

    Re: How to use REST API - setData?

    ‏2013-07-10T06:17:42Z  

    You can use the HTTP Client  integration service provided in the system toolkit. But, as Andy said you need to pass in the credentials for user authentication  to the service.

    -Venky

  • vinp
    vinp
    5 Posts

    Re: How to use REST API - setData?

    ‏2013-07-12T06:53:06Z  
    • Vnn
    • ‏2013-07-10T06:17:42Z

    You can use the HTTP Client  integration service provided in the system toolkit. But, as Andy said you need to pass in the credentials for user authentication  to the service.

    -Venky

    Thanks Andy and Venky for reply.

     

        As Andy mentioned yes, I should have put it other way.

     

    I have also tried to update the value using

    myInstance = tw.system.findProcessInstanceByID(tw.local.instance);

    myInstance.businessData.put('first', tw.local.first);

    but unfortunately it doesn't work.

    I am new to BPM and no idea on how to call the HTTP client , so incase you have the steps or the code on how we can do that please let me know.

     

    Thanks,

    VinP

  • AndrewPaier
    AndrewPaier
    842 Posts

    Re: How to use REST API - setData?

    ‏2013-07-12T21:15:52Z  

    I think you really need to take a step back and tell us the overall use case.  The "setData" call is only intended to set the data values on a task, not at the BPD instance layer.  You are asking for tactical directions on how to do something, but we don't have a really good picture of where you want to wind up.  Without such a map we are likely to point you straight off a cliff.

    So I would recommend taking a step back from your tactical goal (update data at the BPD layer) and explain the overall use case so we can help you.  For example -

    I have a business process that is to do some really cool business stuff.  The problem is that when XYZ happens we need to change the data that is currently at the process level because it has the following impacts.  Are there any recommendations you can make about how we could handle this use case?

    Andrew Paier  |  Director  |  BP3 Global, Inc.
    BP3 Global's Website  |  Twitter  |  Linkedin  |  Google+  |  Blogs

     

  • atummidi
    atummidi
    41 Posts

    Re: How to use REST API - setData?

    ‏2013-07-13T16:37:14Z  

    I think you really need to take a step back and tell us the overall use case.  The "setData" call is only intended to set the data values on a task, not at the BPD instance layer.  You are asking for tactical directions on how to do something, but we don't have a really good picture of where you want to wind up.  Without such a map we are likely to point you straight off a cliff.

    So I would recommend taking a step back from your tactical goal (update data at the BPD layer) and explain the overall use case so we can help you.  For example -

    I have a business process that is to do some really cool business stuff.  The problem is that when XYZ happens we need to change the data that is currently at the process level because it has the following impacts.  Are there any recommendations you can make about how we could handle this use case?

    Andrew Paier  |  Director  |  BP3 Global, Inc.
    BP3 Global's Website  |  Twitter  |  Linkedin  |  Google+  |  Blogs

     

    Hi,

    As andrew mentioned getdata and setdata rest apis are basically to know what happened inside the activity(Task) when BO is passed to it from BPD.

    However this is in reply to another question, If you want to make any REST APi call from server side ..Drag the "READ from HTTP" integration service from system data toolkit and pas the necessary info like rest url,param,authntication..and thats it you are done. Plase let me know if you have issues with this method.

  • atummidi
    atummidi
    41 Posts

    Re: How to use REST API - setData?

    ‏2013-07-13T17:10:58Z  

    I think you really need to take a step back and tell us the overall use case.  The "setData" call is only intended to set the data values on a task, not at the BPD instance layer.  You are asking for tactical directions on how to do something, but we don't have a really good picture of where you want to wind up.  Without such a map we are likely to point you straight off a cliff.

    So I would recommend taking a step back from your tactical goal (update data at the BPD layer) and explain the overall use case so we can help you.  For example -

    I have a business process that is to do some really cool business stuff.  The problem is that when XYZ happens we need to change the data that is currently at the process level because it has the following impacts.  Are there any recommendations you can make about how we could handle this use case?

    Andrew Paier  |  Director  |  BP3 Global, Inc.
    BP3 Global's Website  |  Twitter  |  Linkedin  |  Google+  |  Blogs

     

    Hi,

    As andrew mentioned getdata and setdata rest apis are basically to know what happened inside the activity(Task) when BO is passed to it from BPD.

    However this is in reply to another question, If you want to make any REST APi call from server side ..Drag the "READ from HTTP" integration service from system data toolkit and pas the necessary info like rest url,param,authntication..and thats it you are done. Plase let me know if you have issues with this method.