I have a problem when I try to consuming the web service, the error is:
The request failed with status code: 400
{"error":
{"code":"BadArgument","message":"Invalid argument provided.",
"details":[{"code":"BatchJobInputsNotSpecified","message":"The following required input(s) were not specified with the request: input1. Please ensure all input data is specified and try again."}]}}
I don't know how to solve that, because in the code I send input1.
Please help me, thanks.
let req = require("request");
const uri = "bla";
const apiKey = "key";
let data = {
"Inputs": {
"input1":
[
{
'IdEmpleado': "20000",
'NivelSatisfaccion': "0.38",
'SatisfaccionLaboral_Disc': "Insatisfecho",
'UltimaEvaluacion': "0.53",
'UltimaEvaluacion_Disc': "Media",
'ProyectosRealizados': "2",
'ProyectosRealizados_Disc': "[2-3]",
'HorasMensuales': "157",
'HorasMensuales_Disc': "[150-199]",
'Antiguedad': "3",
'Antiguedad_Disc': "[2-4]",
'AccidentesTrabajo': "0",
'AccidentesTrabajo_Disc': "NO",
'Ascendido': "0",
'Ascendido_Disc': "NO",
'AreaTrabajo': "Ventas",
'NivelSalarial': "Bajo",
'Renuncia': "1",
'Renuncia_Disc': "SI"
}
],
},
"GlobalParameters": {}
}
The scoring uri expects the body of the request to be a JSON document with the following structure:
{
"data":
[
<model-specific-data-structure>
]
}
The structure of the data needs to match what the scoring script and model in the service expect. Please follow the following document for more information.
Related
I have been trying to figure out how to do 2fa with webauthn and I have the registration part working. The details are really poorly documented, especially all of the encoding payloads in javascript. I am able to register a device to a user, but I am not able to authenticate with that device. For reference, I'm using these resources:
https://github.com/cedarcode/webauthn-ruby
https://www.passwordless.dev/js/mfa.register.js
And specifically, for authentication, I'm trying to mimic this js functionality:
https://www.passwordless.dev/js/mfa.register.js
In my user model, I have a webauthn_id, and several u2f devices, each of which has a public_key and a webauthn_id.
In my Rails app, I do:
options = WebAuthn::Credential.options_for_get(allow: :webauthn_id)
session[:webauthn_options] = options
In my javascript, I try to mimic the js file above and I do (this is embedded ruby):
options = <%= raw #options.as_json.to_json %>
options.challenge = WebAuthnHelpers.coerceToArrayBuffer(options.challenge);
options.allowCredentials = options.allowCredentials.map((c) => {
c.id = WebAuthnHelpers.coerceToArrayBuffer(c.id);
return c;
});
navigator.credentials.get({ "publicKey": options }).then(function (credentialInfoAssertion)
{
// send assertion response back to the server
// to proceed with the control of the credential
alert('here');
}).catch(function (err)
{
debugger
console.error(err); /* THIS IS WHERE THE ERROR IS THROWN */
});
The problem is, I cannot get past navigator.credentials.get, I get this error in the javascript console:
TypeError: CredentialsContainer.get: Element of 'allowCredentials' member of PublicKeyCredentialRequestOptions can't be converted to a dictionary
options at the time navigator.credentials.get is called looks like this:
I've tried every which way to convert my db-stored user and device variables into javascript properly encoded and parsed variables but cannot seem to get it to work. Anything obvious about what I'm doing wrong?
Thanks for any help,
Kevin
UPDATE -
Adding options json generated by the server:
"{\"challenge\":\"SSDYi4I7kRWt5wc5KjuAvgJ3dsQhjy7IPOJ0hvR5tMg\",\"timeout\":120000,\"allowCredentials\":[{\"type\":\"public-key\",\"id\":\"OUckfxGNLGGASUfGiX-1_8FzehlXh3fKvJ98tm59mVukJkKb_CGk1avnorL4sQQASVO9aGqmgn01jf629Jt0Z0SmBpDKd9sL1T5Z9loDrkLTTCIzrIRqhwPC6yrkfBFi\"},{\"type\":\"public-key\",\"id\":\"Fj5T-WPmEMTz139mY-Vo0DTfsNmjwy_mUx6jn5rUEPx-LsY51mxNYidprJ39_cHeAOieg-W12X47iJm42K0Tsixj4_Fl6KjdgYoxQtEYsNF-LPhwtoKwYsy1hZgVojp3\"}]}"
This is an example of the serialised JSON data returned by our implementation:
{
"challenge": "MQ1S8MBSU0M2kiJqJD8wnQ",
"timeout": 60000,
"rpId": "identity.acme.com",
"allowCredentials": [
{
"type": "public-key",
"id": "k5Ti8dLdko1GANsBT-_NZ5L_-8j_8TnoNOYe8mUcs4o",
"transports": [
"internal"
]
},
{
"type": "public-key",
"id": "LAqkKEO99XPCQ7fsUa3stz7K76A_mE5dQwX4S3QS6jdbI9ttSn9Hu37BA31JUGXqgyhTtskL5obe6uZxitbIfA",
"transports": [
"usb"
]
},
{
"type": "public-key",
"id": "nbN3S08Wv2GElRsW9AmK70J1INEpwIywQcOl6rp_DWLm4mcQiH96TmAXSrZRHciZBENVB9rJdE94HPHbeVjtZg",
"transports": [
"usb"
]
}
],
"userVerification": "discouraged",
"extensions": {
"txAuthSimple": "Sign in to your ACME account",
"exts": true,
"uvi": true,
"loc": true,
"uvm": true
}
}
This is parsed to an object and the code used to coerce those base64url encoded values is:
credentialRequestOptions.challenge = WebAuthnHelpers.coerceToArrayBuffer(credentialRequestOptions.challenge);
credentialRequestOptions.allowCredentials = credentialRequestOptions.allowCredentials.map((c) => {
c.id = WebAuthnHelpers.coerceToArrayBuffer(c.id);
return c;
});
Hope that helps. The JSON data is retreived via a fetch() call and the byte[] fields are encoded as base64url on the serverside.
Building a RestAPI with Postman.
I have some JSON data:
{
"progress-update": {
"#type": "parallel-progress",
"job": {
"#href": "/api/space/job-management/jobs/4691268"
},
"taskId": 4691268,
"jobName": "Compare Config-4691268",
"state": "DONE",
"status": "SUCCESS",
"percentage": 100,
"data": "<![CDATA[Total requests: 3<br>InSync count : 3<br>OutOfSync count : 0<br>]]>",
"subTask": [
{
I want to pull the "state" value into an environment Variable that i can then use to determine wether to continue on to the next request or wait until the state is DONE.
The problem i'm running into is "progress-update": has a hyphen in it, causing my script to not recognize it.
var jsonData = JSON.parse(responseBody);
pm.environment.set("JobStatus", jsonData.progress-update.state);
Postman returns the following error:
There was an error in evaluating the test script: ReferenceError:
update is not defined
You should be able to access your JSON data with
var jsonData = JSON.parse(responseBody);
pm.environment.set("JobStatus", jsonData['progress-update'].state);
using the object bracket notation
I need help in my one issue. I have write the program in that I am use map in node.js.
I am testing this program using postman by sending JSON structure, however I am not get specific value in console which I am printing.
Please see below code .
async CreateProduceMVPRateAsset(data, callback) {
// Create a new file system based wallet for managing identities.
var ProducePRICE = {};
var MVPRATE = new Map();
var MVPPRICE =[];
var MVPPRICE_BS ={};
var MVPPRICE_LB ={};
var PRODUCENAME = data.PRODUCE
console.log('PRODUCENAME', PRODUCENAME);
var COUNTRY = data.COUNTRY;
console.log('COUNTRY', COUNTRY);
var STATE = data.STATE;
console.log('STATE', STATE);
MVPRATES = data.MVPRATES;
console.log('MVPRATERATE', MVPRATES); // not getting value of MVPRATES from request body
}
JSON structure which is sending using POSTMAN
{
"username": "admin2",
"PRODUCE": "Apple",
"STATE": "MI",
"COUNTRY": "US",
"MVPRATES": {
"fuji": {
"VARIETY": "fuji",
"RATE": [
{
"UNIT": "Bussel",
"CURRENCY": "USD",
"VALUE": 10.25,
"UIDISPLAY": true
}
]
},
"gala": {
"VARIETY": "gala",
"RATE": [
{
"UNIT": "Bussel",
"CURRENCY": "USD",
"VALUE": 10.25,
"UIDISPLAY": true
}
]
}
}
}
output
Any help very appreciable
Thanks
Abhijeet
That's how logs will show up for the non-primitive type of data. Try stringifying the response like:
MVPRATES = data.MVPRATES;
console.log('MVPRATERATE', JSON.stringify(MVPRATES));
This will help you in printing actual values to the logs. A better approach will be to use a logging module like winston and configure all such things and many more.
Sorry to waste you all time I think I miss the var in front of MVPRATES. It should be
var MVPRATES = data.MVPRATES;
I'm trying to access the Google Classroom API with Javascript and am running into a syntax problem when trying to create a student.
The relevant code is
function createStudent () {
var course_id = '146694xxx'
var enrollment_code = '7ytxxx'
var student = {
userId: 'xxx#gmail.com'
}
student = gapi.client.classroom.courses.students.create({courseId:course_id,enrollmentCode:enrollment_code, params: student}).execute();
}
The problem is with the named parameter for the student object. It is where I have "params". I have tried every name I can think of like requestBody, body and a million others. The error I get is
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"params\" at 'student': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "student",
"description": "Invalid JSON payload received. Unknown name \"params\" at 'student': Cannot find field."
}
]
}
]
}
}
How should I be representing that request body object in the call?
Thanks.
Harry
I am using the body-parser to parse incoming JSON object in a POST message. I would like to store a particular value from the JSON into a variable to be sent to a database later.
Here is a snippet:
var http = require('http');
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
// Required to process the HTTP body.
// req.body has the Object while req.rawBody has the JSON string.
app.use(bodyParser.json()); // for parsing application/json
app.post('/', function(req, res){
var tropo = new TropoWebAPI();
parameters = req.body['session']['parameters'];
callerID = req.body['session']['from']['id'];
console.log(callerID);
if(callerID = 1234567)
{
\\Intentionally kept out
}
However, it fails with this TypeError: Cannot read property 'id' of undefined
#malix This is what the JSON object is:
"session": {
"id": "89c3b5d830dd8bb8b372f802aadbdfc9",
"accountId": "1234567",
"applicationId": "1234567",
"timestamp": "2016-06-23T17:09:48.685Z",
"userType": "HUMAN",
"initialText": null,
"callId": "7ab0b9306af2139a1a2e6cc8b7bd7af9",
"to": {
"id": "408XXXYYYY",
"name": "408XXXYYYY",
"channel": "VOICE",
"network": "SIP"
},
"from": {
"id": "408ZZZAAAA",
"name": "408ZZZAAAA",
"channel": "VOICE",
"network": "SIP"
},
}
I am trying to extract 408ZZZAAAA
Please assist.
I figured this out. Turns out the first POST message does give me the required result. The error only shows because my APP is configured to trigger a second POST from the source client. This second POST which triggers the same app.post(), does not have the "from" object all together. Therefore the error shows up on the second try, but I get what I need in the first post itself.