im trying to do an update operation from angular 2 but i dont know how to pass the element parameter
in the vtigercrm.log i see DEBUG webservice -
array ('element' => NULL)
which leads to this
"error": {
"code": "ACCESS_DENIED",
"message": "Permission to perform the operation is denied for id",
i tryied passing the following object as a JSON
{
"subject":"test2",
"assigned_user_id":"19x1",
"date_start":"2016-11-15",
"time_start":"12:00:00",
"due_date":"2016-11-15",
"time_end":"14:00:00",
"recurringtype":"",
"duration_hours":"2",
"duration_minutes":"0",
"parent_id":"",
"eventstatus":"Planned",
"sendnotification":"0",
"activitytype":"Call",
"location":"",
"createdtime":"2016-11-15 11:31:19",
"modifiedtime":"2016-11-15 11:31:19",
"taskpriority":"",
"notime":"0",
"visibility":"Public",
"modifiedby":"19x1",
"description":"",
"reminder_time":"",
"contact_id":"",
"latitud":"",
"longitud":"",
"id":"18x22029"
}
the same thing as encodeURI and encodeURIComponent but nothing works
I had a similar error, and I found a subtle difference in the JSON. When a result was returned, the json object is the first element in an array. But for sending, it needs to be just the object, not an array.
<?php
//decode the json encode response from the server.
$jsonResponse = json_decode( $response->getBody(), true );
//Get first array element for sending back with update
$objectJson = json_encode($jsonResponse[ 'result' ][0]);
?>
Whenever I tried sending the original response, I received an error: {"success":false,"error":{"code":"ACCESS_DENIED","message":"Permission to perform the operation is denied for id"}}
This error message can be due to:
Object ID not mentionned/correct in the JSON objet that you send as the parameter "element"
Vtiger Session ID not sent/correct in the parameter "sessionName"
See here an example (in PHP) of how to pass the object to perform an update
Related
I am trying to run a script where postman sends a Get request, and if the get response contains a certain variable to then run a Post request. How do i do this?
(also is there a way to run a get request hourly)
In pre-requisite add:
// set initial value
const method = pm.variables.get("method")
// set initial value as GET if method is undefined
method ? null : pm.variables.set("method", "GET")
// Set this as method
pm.request.method =method
in test script add :
// the condition check
if (pm.response.json().somevalue === "somevalue") {
//then change the method
pm.variables.set("method", "POST")
//call the same request again using setNExtRequest
// pm.info.reqeustName gives current request's name
postman.setNextRequest(pm.info.requestName)
}
Hi so I am setting up some Integration tests (using Xunit) and I would like to run an Assert to check whether the correct custom error message is returned.
This is the data I need to get is in the following response see image...
detail: "Username must be unique" Don't worry this message will be modified to be more useful later on I am just wanting to get it working first
Required Info
This is the current code...
//Act
response = await _httpClient.PostAsync("CompleteUserSetup", formContent);
//Assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode) ; //Bad request should be returned
//TODO: check custom error message is correct
So hoping for...
ASSERT.Equal("Username must be unique", some code to get detail from response)
Okay so I figured out how to get the data I needed. I just needed to convert the result into an object and then I was able to pull the detail data that I needed.
var resultModel = await System.Text.Json.JsonSerializer.DeserializeAsync<Result>(response.Content.ReadAsStream(), JsonSerializerHelper.DefaultDeserialisationOptions);
var errorMessage = resultModel.detail;
I need help for this kind of error when running this will happen object [] , []
Geocoder.getFromLatLng(28.6139,77.2090).then(
json => {
var addressComponent = json.results[0].address_components[0];
alert(addressComponent);
}, error => {
alert(error+"CATCH");
} )
It looks like you are trying to alert an object doing so usually results in getting the following response:
[object Object]
Which isn't really useful. You can solve this by using JSON.stringify
alert(JSON.stringify(addressComponent)) or alert(JSON.stringify(error))
Doing a reverse geocode lookup on the coordinates gives the following alert when I use JSON.stringify
You can read more about JSON.stringify here in the docs.
The JSON.stringify() method converts a JavaScript object or value to a JSON string
While using alert is useful, I prefer using console.warn as you would get something like this, which means you don't have to stringify every response
I have an array of objects $arr and an object has a property named as jsonData which contains json data in a string, how to parse that string to actual JSON object and retrieve lets say value for key name? I tried this:
#foreach ($obj in $arr)
#set ($jsonData = "#evaluate(${obj.jsonData})")
$jsonData.get("name") ## <-- not working
#end
If anyone using velocity in AWS API Gateway ends up here, you can use AWS'
$util.parseJson() to covert a string to JSON.
Make sure you note if your string is using single or double quotes. You may need to use $util.escapeJavaScipt.replaceAll() before parsing the string.
Fixed it like this:
#foreach ($obj in $arr)
#set( $jsonData = '#set( $jsonData = ' + $obj.jsonData + ' )' )
#evaluate ($jsonData)
$jsonData.get("name") ##<-- works now
#end
I was using velocity 1.7
This is mainly AWS lambda (in python) response template related.. so.. if you want to return custom response code with json it is easy to return JSON in node js but when it comes to python as per i know, we cant raise dict as a value. So.. this may help. If you are doing like..
raise Exception({"responseCode": 400, "response": "missing :\"recipientCount\""})
It will throw exception in errorMessage key and value as a string.
To overcome this..
Add response code 400 in Method Response
regExp in Integration Response :
.*'responseCode': 400.*
Add Body Mapping Template as application/json:
$util.escapeJavaScript( $input.path('$.errorMessage')).replaceAll("\\'",'\"')
Make sure you are not using single quotes in value in exception string.
Wrong:
raise Exception({"responseCode": 400, "response": "missing :'recipientCount'"})
Right:
raise Exception({"responseCode": 400, "response": "missing :\"recipientCount\""})
I know it is not best solution... but this is the only solution i have found. Feel free if you have better solution.
I have just got this error a few days ago. Whenever I try to run
this.store.queryRecord('user', {filter:{username : params.username}});
It shows error: Assertion Failed: Expected the primary data returned by the serializer for a queryRecord response to be a single object but instead it was an array.
What is the problem here?
You backend should return one object not array.
Found a way to avoid this problem. Instead of queryRecord ( which seems to be changed by ember-data developer team ), I use store.query like this:
this.store.query('user', {filter:{username : params.username}}).then(function(user){return user.get('firstObject')});
I encountered similar situation , had 2 routes
this.get('/clients', function() {return {data: [allClientsDataJson]};});
this.get('/clients:id', function() {return {data: [oneClientDataJson]};});
But after using queryRecord i got same error. Thing was that second route was never called and first one was called in both causes. So instead of single result there was array with all results in second call.
After knowing only first one is always called i edited it to :
this.get('/clients', function(db, request) {
if(!Ember.isEmpty(request.queryParams)) { return oneClientDataJson
} else { return allClientsDataJson }