# REST call to uploaded script results in "Missing engine for language: string"

**URL:** <https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135>\
**Category:** Sonatype Nexus Repository\
**Created:** [January 30, 2019, 12:04pm UTC](https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135 "2019-01-30T12:04:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alx](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Alx](https://community.sonatype.com/u/Alx)\
**Post date:** [January 30, 2019, 12:04pm UTC](https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135/1 "2019-01-30T12:04:07Z")

</div>

Hi,  
I have two scripts uploaded, which list as  
[ {  
“name” : “test”,  
“content” : “println(‘Hello test’)”,  
“type” : “string”  
}, {  
“name” : “helloarg”,  
“content” : “String.valueOf(args)”,  
“type” : “string”  
} ]  
Whichever I run from the API page or the commandline, I get a Json result : “Missing enging for language: string”:

$ curl -X POST -u admin:admin123 --header “Content-Type: text/plain” “[http://localhost:8081/service/rest/v1/script/helloarg/run](http://localhost:8081/service/rest/v1/script/helloarg/run)” -d “Hello”  
\< HTTP/1.1 400 Bad Request  
{  
“name” : “helloarg”,  
“result” : “Missing engine for language: string”  
}

$ curl -X POST -u admin:admin123 --header “Content-Type: text/plain” “[http://localhost:8081/service/rest/v1/script/test/run](http://localhost:8081/service/rest/v1/script/test/run)”  
{  
“name” : “test”,  
“result” : “Missing engine for language: string”  
}

In the logViewer I see that this is a java.lang.IllegalStateException.  
In any case, it is not caused by the Json type argument “string”, because “String” results in the same.  
Eventually I need to pass an argument with value of a specific GAV from Jenkins, after having released successfully, to run the Nexus script on this GAV.

---

<div class="post-metadata">

**Author:** ![rseddon](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/rseddon/32/341_2.png) [@rseddon](https://community.sonatype.com/u/rseddon)\
**Post date:** [January 30, 2019, 2:45pm UTC](https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135/2 "2019-01-30T14:45:23Z")

</div>

You need to set the content-type header to “application/json”:

`--header "Content-Type: application/json"`

Rich

---

<div class="post-metadata">

**Author:** ![atselvan](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@atselvan](https://community.sonatype.com/u/atselvan)\
**Post date:** [January 30, 2019, 3:50pm UTC](https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135/3 "2019-01-30T15:50:13Z")

</div>

@Alx

This is what I can make out if it!

Below is my script:

```auto
import groovy.json.JsonOutput
import groovy.json.JsonSlurper

def input = new JsonSlurper().parseText(args)
def output = [:]

log.info(" ***********************************************")
log.info("Running the script Test")
log.info(" ***********************************************")

output.put("status", "200 OK")
output.put("g", input.g)
output.put("a", input.g)
output.put("v", input.v)

return JsonOutput.toJson(output)

```

Then I create the JSON file as:

```auto
{
  “name” : “test”,
  “type” : “groovy”
  “content” : “I read the above script file here / you can also copy paste it here”,
}

```

Then while running the script you can pass a json style string to the script. The script will be able to parse it!

Req: [https://localhost:8443/service/rest/v1/script/test/run](https://localhost:8443/service/rest/v1/script/test/run)  
payload: {“g”: “com.company”,“a”: “artifact”,“v”: “1.0.0”}  
Header : Basic Auth and Content-Type: text/plain  
Resp:

{  
“name”: “test”,  
“result”: “{“status”:“200 OK”,“g”:“com.company”,“a”:“com.company”,“v”:“1.0.0”}”  
}

The script just formats and return the same to me. I can then also parse this info.

Since a week I am writing these function into a Golang CLI, check it out if it helps you: [GitHub - atselvan/nexus3-repository-cli: Nexus 3 CLI](https://github.com/atselvan/nexus3-repository-cli)

---

<div class="post-metadata">

**Author:** ![Alx](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Alx](https://community.sonatype.com/u/Alx)\
**Post date:** [January 30, 2019, 7:27pm UTC](https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135/4 "2019-01-30T19:27:50Z")

</div>

Thank you, I will definitely give it a try!  
Allthough it looks like a Mime-type problem, the system/API page does not seem to work consistently with application/json.

This still works with a “onelined” script, but if it works it works!  
The Sonatype complex-script example shows it can also be done with a REST call.

---

<div class="post-metadata">

**Author:** ![Alx](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Alx](https://community.sonatype.com/u/Alx)\
**Post date:** [January 30, 2019, 8:53pm UTC](https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135/5 "2019-01-30T20:53:25Z")

</div>

Indeed, I even get result without the Mime-type:

curl -X POST -u admin:admin123 “[http://localhost:8081/service/rest/v1/script/test/run](http://localhost:8081/service/rest/v1/script/test/run)” “{“g”: “com.company”,“a”: “artifact”,“v”: “1.0.0”}”

Thanks !

---

<div class="post-metadata">

**Author:** ![Alx](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Alx](https://community.sonatype.com/u/Alx)\
**Post date:** [January 31, 2019, 10:36am UTC](https://community.sonatype.com/t/rest-call-to-uploaded-script-results-in-missing-engine-for-language-string/1135/6 "2019-01-31T10:36:13Z")

</div>

Rich, thanks for the reply, but If I upload this script through the API page via add  
{  
“name”: “hello”,  
“content”: “log.info(“Hello”)”,  
“type”: “string”  
}  
and call it through the run option I get the HTTP 400 / Bad Request: “Missing engine for language: string” result.  
I can not choose alternative Mime-types for either action.

Running the script by cUrl the Mime-type does not matter for the exception in the logViewer.

However, the solution offered by atselvan works.
