Learning Locker and SCORM-to-xAPI-Wrapper - scorm2004

I have two versions of Learning Locker installed. In one version the statements are received however I can't view any of my previous statements as LL seems to be stuck
When I use my new version of LL, no statements are received however I do get a load of errors.
xapiwrapper.min.js:2 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
xapiwrapper.min.js:2 GET http://52.16.190.132/data/xAPI/activities/profile?activityId=http%3A%2F%2F1…fileId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Factivity-profile 404 (Not Found)
xapiwrapper.min.js:2 XHR finished loading: GET "http://52.16.190.132/data/xAPI/activities/profile?activityId=http%3A%2F%2F1…fileId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Factivity-profile".
xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/activities/profile?activityId=http%3A%2F%2F1…fileId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Factivity-profile".
xapiwrapper.min.js:2 GET http://52.16.190.132/data/xAPI/activities/state?activityId=http%3A%2F%2F10.…D&stateId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Fattempt-state 400 (Bad Request)
xapiwrapper.min.js:2 XHR finished loading: GET "http://52.16.190.132/data/xAPI/activities/state?activityId=http%3A%2F%2F10.…D&stateId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Fattempt-state".
xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":"homePageis not a valid irl in account. ,Anaccountmust have anameand ahomePage.,agentis not a valid actorIdentifier in params. ","trace":"#0 \/var\/www\/learninglocker\/app\/controllers\/xapi\/BaseController.php(114): Controllers\\xAPI\\BaseController->validateValue('agent', Array, 'agent')\n#1 \/var\/www\/learninglocker\/app\/controllers\/xapi\/DocumentController.php(269): Controllers\\xAPI\\BaseController->requiredValue('agent', '{\"account\":{\"ho...', 'agent')\n#2 \/var\/www\/learninglocker\/app\/controllers\/xapi\/DocumentController.php(30): Controllers\\xAPI\\DocumentController->checkParams(Array, Array, Array)\n#3 \/var\/www\/learninglocker\/app\/controllers\/xapi\/DocumentController.php(68): Controllers\\xAPI\\DocumentController->getShowData()\n#4 \/var\/www\/learninglocker\/app\/controllers\/xapi\/BaseController.php(53): Controllers\\xAPI\\DocumentController->show()\n#5 \/var\/www\/learninglocker\/app\/controllers\/xapi\/BaseController.php(36): Controllers\\xAPI\\BaseController->get()\n#6 [internal function]: Controllers\\xAPI\\BaseController->selectMethod()\n#7 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Controller.php(231): call_user_func_array(Array, Array)\n#8 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerDispatcher.php(93): Illuminate\\Routing\\Controller->callAction('selectMethod', Array)\n#9 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerDispatcher.php(62): Illuminate\\Routing\\ControllerDispatcher->call(Object(Controllers\\xAPI\\StateController), Object(Illuminate\\Routing\\Route), 'selectMethod')\n#10 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(962): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request), 'Controllers\\\\xAP...', 'selectMethod')\n#11 [internal function]: Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#12 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Route.php(109): call_user_func_array(Object(Closure), Array)\n#13 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(1028): Illuminate\\Routing\\Route->run(Object(Illuminate\\Http\\Request))\n#14 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(996): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))\n#15 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application.php(776): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))\n#16 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application.php(746): Illuminate\\Foundation\\Application->dispatch(Object(Illuminate\\Http\\Request))\n#17 \/var\/www\/learninglocker\/vendor\/asm89\/stack-cors\/src\/Asm89\/Stack\/Cors.php(51): Illuminate\\Foundation\\Application->handle(Object(Illuminate\\Http\\Request), 1, true)\n#18 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Session\/Middleware.php(72): Asm89\\Stack\\Cors->handle(Object(Illuminate\\Http\\Request), 1, true)\n#19 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Cookie\/Queue.php(47): Illuminate\\Session\\Middleware->handle(Object(Illuminate\\Http\\Request), 1, true)\n#20 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Cookie\/Guard.php(51): Illuminate\\Cookie\\Queue->handle(Object(Illuminate\\Http\\Request), 1, true)\n#21 \/var\/www\/learninglocker\/vendor\/stack\/builder\/src\/Stack\/StackedHttpKernel.php(23): Illuminate\\Cookie\\Guard->handle(Object(Illuminate\\Http\\Request), 1, true)\n#22 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application.php(642): Stack\\StackedHttpKernel->handle(Object(Illuminate\\Http\\Request))\n#23 \/var\/www\/learninglocker\/public\/index.php(49): Illuminate\\Foundation\\Application->run()\n#24 {main}"} )http://52.16.190.132/data/xAPI/activities/state?activityId=http%3A%2F%2F10.…D&stateId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Fattempt-state
xapiwrapper.min.js:2 POST http://52.16.190.132/data/xAPI/activities/state?activityId=http%3A%2F%2F10.…D&stateId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Fattempt-state 400 (Bad Request)
xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/activities/state?activityId=http%3A%2F%2F10.…D&stateId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Fattempt-state".
xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":"homePageis not a valid irl in account. ,Anaccountmust have anameand ahomePage.,agentis not a valid actorIdentifier in params. ","trace":"#0 \/var\/www\/learninglocker\/app\/controllers\/xapi\/BaseController.php(114): Controllers\\xAPI\\BaseController->validateValue('agent', Array, 'agent')\n#1 \/var\/www\/learninglocker\/app\/controllers\/xapi\/DocumentController.php(269): Controllers\\xAPI\\BaseController->requiredValue('agent', '{\"account\":{\"ho...', 'agent')\n#2 \/var\/www\/learninglocker\/app\/controllers\/xapi\/DocumentController.php(30): Controllers\\xAPI\\DocumentController->checkParams(Array, Array, Array)\n#3 \/var\/www\/learninglocker\/app\/controllers\/xapi\/DocumentController.php(80): Controllers\\xAPI\\DocumentController->getShowData()\n#4 \/var\/www\/learninglocker\/app\/controllers\/xapi\/BaseController.php(38): Controllers\\xAPI\\DocumentController->store()\n#5 [internal function]: Controllers\\xAPI\\BaseController->selectMethod()\n#6 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Controller.php(231): call_user_func_array(Array, Array)\n#7 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerDispatcher.php(93): Illuminate\\Routing\\Controller->callAction('selectMethod', Array)\n#8 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerDispatcher.php(62): Illuminate\\Routing\\ControllerDispatcher->call(Object(Controllers\\xAPI\\StateController), Object(Illuminate\\Routing\\Route), 'selectMethod')\n#9 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(962): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request), 'Controllers\\\\xAP...', 'selectMethod')\n#10 [internal function]: Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#11 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Route.php(109): call_user_func_array(Object(Closure), Array)\n#12 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(1028): Illuminate\\Routing\\Route->run(Object(Illuminate\\Http\\Request))\n#13 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(996): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))\n#14 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application.php(776): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))\n#15 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application.php(746): Illuminate\\Foundation\\Application->dispatch(Object(Illuminate\\Http\\Request))\n#16 \/var\/www\/learninglocker\/vendor\/asm89\/stack-cors\/src\/Asm89\/Stack\/Cors.php(51): Illuminate\\Foundation\\Application->handle(Object(Illuminate\\Http\\Request), 1, true)\n#17 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Session\/Middleware.php(72): Asm89\\Stack\\Cors->handle(Object(Illuminate\\Http\\Request), 1, true)\n#18 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Cookie\/Queue.php(47): Illuminate\\Session\\Middleware->handle(Object(Illuminate\\Http\\Request), 1, true)\n#19 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Cookie\/Guard.php(51): Illuminate\\Cookie\\Queue->handle(Object(Illuminate\\Http\\Request), 1, true)\n#20 \/var\/www\/learninglocker\/vendor\/stack\/builder\/src\/Stack\/StackedHttpKernel.php(23): Illuminate\\Cookie\\Guard->handle(Object(Illuminate\\Http\\Request), 1, true)\n#21 \/var\/www\/learninglocker\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application.php(642): Stack\\StackedHttpKernel->handle(Object(Illuminate\\Http\\Request))\n#22 \/var\/www\/learninglocker\/public\/index.php(49): Illuminate\\Foundation\\Application->run()\n#23 {main}"} )http://52.16.190.132/data/xAPI/activities/state?activityId=http%3A%2F%2F10.…D&stateId=http%3A%2F%2Fadlnet.gov%2Fxapi%2Fprofile%2Fscorm%2Fattempt-state
xapiwrapper.min.js:2 POST http://52.16.190.132/data/xAPI/statements 400 (Bad Request)
xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/statements".
xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":["testshould be a validLocker\XApi\IRIinstatement.actor.account.homePage"]} )http://52.16.190.132/data/xAPI/statements
jquery.min.js:4 XHR finished loading: GET "http://10.3.0.171/moodle/pluginfile.php/29/mod_scorm/content/12/models_html5/quiz.html".xapiwrapper.min.js:2 POST http://52.16.190.132/data/xAPI/statements 400 (Bad Request)
xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/statements".
xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":["testshould be a validLocker\XApi\IRIinstatement.actor.account.homePage"]} )http://52.16.190.132/data/xAPI/statements
yui_combo.php?rollup/3.17.2/yui-moodlesimple.js&rollup/1426267206/mcore-debug.js:24186 XHR finished loading: GET "http://10.3.0.171/moodle/lib/yui/build/moodle-core-checknet/assets/checknet.txt?time=1426596376630".
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 POST http://52.16.190.132/data/xAPI/statements 400 (Bad Request)
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/statements".
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":["testshould be a validLocker\XApi\IRIinstatement.actor.account.homePage"]} )http://52.16.190.132/data/xAPI/statements
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 POST http://52.16.190.132/data/xAPI/statements 400 (Bad Request)
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/statements".
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":["testshould be a validLocker\XApi\IRIinstatement.actor.account.homePage"]} )http://52.16.190.132/data/xAPI/statements
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 POST http://52.16.190.132/data/xAPI/statements 400 (Bad Request)
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/statements".
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":["testshould be a validLocker\XApi\IRIinstatement.actor.account.homePage"]} )http://52.16.190.132/data/xAPI/statements
/moodle/pluginfile.php/29/mod_scorm/content/12/apiwrapper_2004.3rd.js:615 SetValue(cmi.total_time, PT71.07S) failed.
404: Data Model Element Is Read Only
/moodle/pluginfile.php/29/mod_scorm/content/12/apiwrapper_2004.3rd.js:615 GetValue(cmi.exit) failed.
405: Data Model Element Is Write Only
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 POST http://52.16.190.132/data/xAPI/statements 400 (Bad Request)
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 XHR finished loading: POST "http://52.16.190.132/data/xAPI/statements".
/moodle/pluginfile.php/29/mod_scorm/content/12/scorm-xapi/xapiwrapper.min.js:2 There was a problem communicating with the Learning Record Store. ( 400 | {"error":true,"success":false,"message":["testshould be a validLocker\XApi\IRIinstatement.actor.account.homePage"]} )
Anyone have any ideas?
Thanks
Stephen

It looks like the LRS is rejecting the statements because the agent object you're using in your requests is not valid. It looks like you're maybe using something like
{
"name": "test",
"account": {
"homePage": "test",
"name": "test"
},
"objectType": "Agent"
}
Whereas to be valid you need to use something like:
{
"name": "test",
"account": {
"homePage": "http://example.com/test",
"name": "test"
},
"objectType": "Agent"
}
If that's not the case, can you add the complete statement you ARE sending to your question. See this blog for more details on valid values for agents.
You also might want to look at TinCanJS as an alternative JS library and SCORM Cloud as an additional LRS for testing content that doesn't work with Learning Locker so you can pin down if the problem is with the content or LRS.

Related

Vertx Web Client throwing HTTP 415 Unsupported Media Type for Multipart/form-data

This service receives the multipart request from mobile client and passes on the request to downstream service for uploading the image. I am seeing 415 Unsupported Media Type in my downstream service
private void makeRequest(HttpRequest<Buffer> httpRequest,
Promise<Object> future,
RequestContext requestContext,
RoutingContext routingContext,
Entry entry) {
MultipartForm multipartForm = MultipartForm.create();
MultiMap attributes = routingContext.request()
.formAttributes();
attributes.forEach(attribute -> {
multipartForm.attribute(attribute.getKey(), attribute.getValue());
});
routingContext.fileUploads()
.forEach(fileUpload -> {
multipartForm.binaryFileUpload(fileUpload.name(), fileUpload.fileName(),
fileUpload.uploadedFileName(), fileUpload.contentType());
});
httpRequest.sendMultipartForm(multipartForm, response -> {
handleResponse(routingContext, future, response, requestContext, entry);
});
}
Getting the below exception
javax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.getMethodRouter(MethodSelectingRouter.java:478)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.access$000(MethodSelectingRouter.java:94)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter$4.apply(MethodSelectingRouter.java:779)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.apply(MethodSelectingRouter.java:371)
API signature of my downstream service
#POST
#Timed
#Path("{userId}/{scope}/upload")
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Produces(MediaType.APPLICATION_JSON)
#ApiOperation("Multipart upload of an image")
Can someone please guide what is wrong in my code snippet or is there any setting which needs to be enabled in vertx server or vertx web client?
Thanks,
Nitish Goyal
I was able to resolve this by explicitly setting the header
.putHeader("content-type", "multipart/form-data")

RESTful client in Unity - validation error

I have a RESTful server created with ASP.Net and am trying to connect to it with the use of a RESTful client from Unity. GET works perfectly, however I am getting a validation error when sending a POST request. At the same time both GET and POST work when sending requests from Postman.
My Server:
[HttpPost]
public IActionResult Create(User user){
Console.WriteLine("***POST***");
Console.WriteLine(user.Id+", "+user.sex+", "+user.age);
if(!ModelState.IsValid)
return BadRequest(ModelState);
_context.Users.Add(user);
_context.SaveChanges();
return CreatedAtRoute("GetUser", new { id = user.Id }, user);
}
My client:
IEnumerator PostRequest(string uri, User user){
string u = JsonUtility.ToJson(user);
Debug.Log(u);
using (UnityWebRequest webRequest = UnityWebRequest.Post(uri, u)){
webRequest.SetRequestHeader("Content-Type","application/json");
yield return webRequest.SendWebRequest();
string[] pages = uri.Split('/');
int page = pages.Length - 1;
if (webRequest.isNetworkError || webRequest.isHttpError){
Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
}
else{
Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
}
}
}
I was trying both with the Json conversion and writing the string on my own, also with the WWWForm, but the error stays.
The error says that it's an unknown HTTP error. When printing the returned text it says:
"One or more validation errors occurred.","status":400,"traceId":"|b95d39b7-4b773429a8f72b3c.","errors":{"$":["'%' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0."]}}
On the server side it recognizes the correct method and controller, however, it doesn't even get to the first line of the method (Console.WriteLine). Then it says: "Executing ObjectResult, writing value of type 'Microsoft.AspNetCore.Mvc.ValidationProblemDetails'".
Here're all of the server side messages:
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST http://localhost:5001/user application/json 53
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'TheNewestDbConnect.Controllers.UserController.Create (TheNewestDbConnect)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
Route matched with {action = "Create", controller = "User"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Create(TheNewestDbConnect.Data.Entities.User) on controller TheNewestDbConnect.Controllers.UserController (TheNewestDbConnect).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
Executing ObjectResult, writing value of type 'Microsoft.AspNetCore.Mvc.ValidationProblemDetails'.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
Executed action TheNewestDbConnect.Controllers.UserController.Create (TheNewestDbConnect) in 6.680400000000001ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'TheNewestDbConnect.Controllers.UserController.Create (TheNewestDbConnect)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 11.3971ms 400 application/problem+json; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
I have no idea what is happening and how to solve it. Any help will be strongly appreciated!
Turned out I was just missing an upload handler. Adding this line solved it: webRequest.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(JsonObject));

Internal Error encountered while invoking CloudML Predict via REST

I have my application running in GAE. This application makes REST call to my CloudML.
Here is the code for that
GoogleCredential credential = GoogleCredential.getApplicationDefault()
.createScoped(Collections.singleton(CLOUDML_SCOPE));
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
HttpRequestInitializer requestInitializer = request -> {
credential.initialize(request);
request.setReadTimeout(0);
};
HttpRequestFactory requestFactory = httpTransport.createRequestFactory(
requestInitializer);
GenericUrl url = new GenericUrl(predictRestUrl);
JacksonFactory jacksonFactory = new JacksonFactory();
JsonHttpContent jsonHttpContent = new JsonHttpContent(jacksonFactory, getPayLoad());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
jsonHttpContent.setWrapperKey("instances");
jsonHttpContent.writeTo(baos);
LOG.info("Executing request... " + baos.toString());
HttpRequest request = requestFactory.buildPostRequest(url, jsonHttpContent);
HttpResponse response = request.execute();
I've set the ReadTimeOut to 0 as I often get read timeout exception.
Now with this code I am often getting the below error response from CloudML
com.google.api.client.http.HttpResponseException: 500 Internal Server Error
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"errors": [
{
"message": "Internal error encountered.",
"domain": "global",
"reason": "backendError"
}
],
"status": "INTERNAL"
}
}
Where we can get the logs for REST call to CloudML? How to debug this further?
We worked with #sag and determined that the 500 error is a result of a timeout due to a long "cold start". If you haven't sent traffic to your model in a while, or if you send enough that we need to spin more instances up, you will hit a "cold start", where one or more instances are spun up. Currently, this can be a lengthy process that sometimes times out on our end and a 500 error may result.
These errors can safely be retried; we recommend using exponential backoff.

jobProgressToken: Jira (Zephyr) Rest API

I am using Jira (Zephyr) rest calls to create Test Cycle and add Tests cases into it. According to information mentioned here1 if I use this rest call to add tests to Cycle then as a response I will get JobProgressToken. JobProgressToken is nothing but will tell the progress of Test Case addition in Test Cycle.
Now the problem which I am facing is I am not getting any output from this JobProgressToken. I tried firing the GET rest call using the format mentioned but I am getting empty response.
Can somebody please explain how to use this JobProgressToken to get the Progress of my task?
I want to verify that the tests which I added to Cycle are added susccessfully or not?
Just ysterday I had the same issue. ZAPI documentation is really confusing. I found the following solution:
GET request for retrieving a job progress has the following form: http://jira/rest/zapi/latest/execution/jobProgress/0001498157843923-5056b64fdb-0001
where 0001498157843923-5056b64fdb-0001 is a value of the particular jobProgressToken
Right after getting a jobProgressToken as a result of some async operation, my code is waiting for the progress to became 1 (it is groing up from zero to 1)
//get the job progress token as a result of some async operation invocation
String jobProgressToken = new JSONObject(zapiResponse).getString("jobProgressToken");
waitAsyncJobToBeCompleted(jobProgressToken);
void waitAsyncJobToBeCompleted(String jobProgressToken) {
double jobProgress;
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
LOG.error("Error while try to make the thread sleeping 500ms. " + e.getLocalizedMessage());
e.printStackTrace();
}
jobProgress = getJobProgress(jobProgressToken);
} while (Double.compare(jobProgress, 1) <0);
private double getJobProgress(String jobProgressToken) {
URI uri = makeUriFromString(String.format(
GET_GetJobProgress, //Get request pattern
connectionParameters.getJiraUrl(),//host
jobProgressToken)); //parameters
HttpResponse response = executeHttpRequestWithResponse(new HttpGet(uri));
String zapiResponse = null;
try {
zapiResponse = EntityUtils.toString(response.getEntity());
LOG.trace("ZAPI RESPONSE: " + zapiResponse);
EntityUtils.consumeQuietly(response.getEntity()); //cleanup the HTTP response
double progress = new JSONObject(zapiResponse).getDouble("progress");
LOG.debug("Job progress: " + progress);
return progress;
} catch (IOException e) {
String err = String.format("Error while getting Zephyr API response: %s",
e.getLocalizedMessage());
LOG.fatal(err);
throw new RestApiException(err, e);
} catch (JSONException e) {
String err = String.format("Error while retrieving the job progress from JSON: %s\n%s",
zapiResponse, e.getLocalizedMessage());
LOG.fatal(err);
throw new RestApiException(err, e);
}
}
This is all magic :)
Following two logs: 1st for cloning test cycle, 2nd for deleting
ZephyrClient.invokeHttpPost - URI=http://jira/rest/zapi/latest/cycle JSON payload={"projectId": "13795","clonedCycleId": 2643,"name": "ZAPI client test","description": "Created With ZAPI client unit test","versionId": "-1"}
ZephyrClient.cloneTestCycle - RESPONSE JSON: {"jobProgressToken":"0001498218783350-5056b64fdb-0001"}
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 1 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":0.56,"message":"","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 0.56
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 1 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":0.98,"message":"","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 0.98
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 2 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":0.98,"message":"","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 0.98
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 3 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":1.0,"message":"Cycle ZAPI client test created successfully.","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 1.0
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/cycle?projectId=13795&versionId=-1 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.invokeHttpDelete - URI=http://jira/rest/zapi/latest/cycle/2727
ZephyrClient.deleteTestCycle - RESPONSE JSON: {"jobProgressToken":"0001498218815183-5056b64fdb-0001"}
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218815183-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 0 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":1.0,"message":"{\"success\":\"Cycle ZAPI client test успешно удален\"}","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 1.0
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/cycle?projectId=13795&versionId=-1 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
P.S. This is not about how it should be done.
This is about how does it work for me ;)

Can spray.io can return 504 if Actor accepting Timedout message?

My server is written using spray-can. Let's say inside the receive function I handle Timeout message like this:
case Timedout( HttpRequest(m,u,_,_,_)) =>
sender ! HttpResponse( status = 500, entity = s"can't process $u request timedout" )
Is it possible that spray-can itself might response with 504 error ?