Could you tell us what you are trying to do? Not how, but what?
Problem is you've said "create issue in Jira SR using REST API" - if you have SR, you don't need to use REST, you have direct access to the Jira you are in. But you might also mean you're trying to create issues from somewhere else (in which case, you might not need SR, as Jira has a REST interface).
We can clarify what the question is and hence get started on a proper answer.
The requirement is when an issue of type Risk is moved to the workflow state of 'Occurred' then validate whether any issue of type "issue" is linked with the parent issue t "Risk", if yes then nothing will happen if no then we need to create an issue of type issue, and the Summary,description from the Risk is used as the Summary,description of the Issue.
I am trying to write the groovy script in validator custom script.
Ok, so nothing to do with REST.
I would do this with a post-function. You should NEVER try to make changes to anything in a validator - a validator is part-way through a process and should only ever say "yes, this is ok", or "no, your data does not fit, so we will not be proceeding with the transition". If you were to put issue updates in a validator, you will start finding them doing very odd things and possibly trashing your database.
So, a post-function on the "go to occurred" transition of the Risk workflow would need to
Go through the links on the current issue
Check if the far end is of type "issue"
If you cannot find one, then create one, copying summary and description from current issue
These two should help you put together code for that:
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event