Errant Facebook SDK Batch request - javascript

I have a Facebook SDK Batch, and one of the requests is returning the following error:
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
Here's the Batch:
FB.api('/', 'POST', {
batch: [
{
method : 'GET',
name : 'user',
relative_url : '/me'
},
{
method: 'GET',
name : 'post-ids',
relative_url: '/group-id/feed?fields=id',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-data',
relative_url : '?ids={result=post-ids:$.data.*.id}&fields=id,actions,application,from,to,message,message_tags,with_tags,picture,place,properties,source,status_type,link,description,caption,attachments,object_id,type,created_time,updated_time,likes.summary(1),comments.summary(1)',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-user-info',
relative_url : '/{result=post-data:$.data.*.from.id}/',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-likes',
relative_url : '?ids={result=post-ids:$.data.*.id}/likes?limit=5000',
omit_response_on_success : false
},
{
method : 'GET',
name : 'post-comments',
relative_url : '?ids={result=post-ids:$.data.*.id}/comments?fields=id,actions,application,from,to,message,message_tags,with_tags,picture,place,properties,source,status_type,link,description,caption,attachments,object_id,type,created_time,updated_time,likes.summary(1)&limit=5000',
omit_response_on_success : false
}
]
}, function (response) {
The fourth request, name post-user-info is the errant request. Basically, for each post, I want to get the information (profile picture in particular) about the user that created the post. What's the best way to do this?

Related

How do I make a good post request for Sabre Rail Search Single Trip? I get 'ERR_BAD_REQUEST' Bad Request Error

https://developer.sabre.com/docs/rest_apis/ground/content_services_rail/search_single_trip/reference-documentation
"requestBody" with "searchCriteria" is required in the POST request.
If I don't specify the "requestBody" I get the "no access privileges" error.
But when I add "requestBody" to the params I get [AxiosError: Request failed with status code 400] {
code: 'ERR_BAD_REQUEST', ...
I don't get it. How should I incorporate "requestBody" with "searchCriteria" into the code and into the request? In the JSON example they even put it inside "payload", when I put "searchCriteria" inside "payload" instead of params.requestBody I get "no privilages" error.
I can't seem to get a single successful response no matter where I put the "requestBody" and "searchCriteria".
const optionsToUse = {
method: 'POST',
url: "https://api-crt.cert.havail.sabre.com/v1/rail/offers/journeys/1S",
params: {
marketingCarrierCode: "1S",
requestBody : {
"searchCriteria" : [ {
"journeyCriteria" : {
"departure" : {
"locationId" : "FRPLY",
"dateTime" : "2022-08-02T07:07"
},
"arrival" : {
"locationId" : "FRLPD"
}
},
"passengerCriteria" : [ {
"passengerCode" : "ADULT"
} ]
} ]
}
},
headers: {
Authorization: "Bearer " + access_token
}
}
axios.request(optionsToUse).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
Wyrun,
You need to pass your body in data not in params and remove your params attribute because the marketingCarrierCode is a param inside the url, not a query param :
const optionsToUse = {
method: 'POST',
url: "https://api-crt.cert.havail.sabre.com/v1/rail/offers/journeys/1S",
data: {
"searchCriteria" : [ {
"journeyCriteria" : {
"departure" : {
"locationId" : "FRPLY",
"dateTime" : "2022-08-02T07:07"
},
"arrival" : {
"locationId" : "FRLPD"
}
},
"passengerCriteria" : [ {
"passengerCode" : "ADULT"
} ]
} ]
},
headers: {
Authorization: "Bearer " + access_token
}
}
(Axios documentation for request config https://axios-http.com/docs/req_config)

How to solve error parsing in dataTables?

I have a function button that carry user info fullname, after clicking the button, it will send fullname and level to an API to be process and the result should be display in dataTable. Unfortunately, I got this error.
This is console.log for console.log(params). {"task_level":3,"fullname":"Administrator"}
Below is console.log for console.log(params).
Both console log is similar to API's result.
I don't know which is proper.
JS 1st Try (1st Ajax to send the parameter to API and after return success hopefully working but not.
"<button type='button' class='btn btn-dark btn-round' onclick='viewTablePerson(""+value.fullname+"")'>View Project</button>"+
function viewTablePerson(fullname){
var level = 3;
var fullname2 = fullname;
var obj = {
task_level : level,
fullname : fullname2
};
var params = JSON.stringify(obj);
console.log(params)
$.ajax({
url : url_api + '/api/user_task',
crossDomain: true,
type : 'POST',
dataType : 'json',
data: params,
success: function(response){
if (response.status == "Success"){
console.log(response)
$('#viewProgress').DataTable({
ajax: {
url: url_api + '/api/user_task',
crossDomain : true,
type : "POST",
cache : false,
dataType : "json",
contentType: false,
processData: true,
data : params,
timeout: 10000,
},
destroy: true,
columns: [
{ data : "task_name"},
{ data : "task_owner"},
{ data : "task_status"}
],
});
}
},
error: function(e){}
});
}
JS 2nd Try
<button type='button' class='btn btn-dark btn-round' onclick='viewTablePerson(""+value.fullname+"")'>View Project</button>"+
function viewTablePerson(fullname){
var level = 3;
var fullname2 = fullname;
var obj = {
task_level : level,
fullname : fullname2
};
var params = JSON.stringify(obj);
console.log(params)
$('#viewProgress').DataTable({
ajax: {
url: url_api + '/api/user_task',
crossDomain : true,
type : "POST",
cache : false,
dataType : "json",
contentType: false,
processData: true,
data : params,
timeout: 10000,
},
destroy: true,
columns: [
{ data : "task_name"},
{ data : "task_owner"},
{ data : "task_status"}
],
});
}
Documentation says:
When using the ajax option to load data for DataTables, a general error can be triggered if the server responds with anything other than a valid HTTP 2xx response.
So, you have to check server-side response instead of search for problems on the front-end.
Also, in your case make sure
the plugin sends request to the same domain from which the current page is loaded;
browser security system doesn't prevent loading of external scripts - for example on http://localhost you cannot Ajax load a script from http://google.com without special measures;
you are specifying a relative path without a domain name (if you are using a single domain);
JSON data in response is a valid.
If you cannot alter the backend system to fix the error, but don't want your end users to see the alert message, you can change DataTables' error reporting mechanism to throw a Javascript error to the browser's console, rather than alerting it:
$.fn.dataTable.ext.errMode = 'throw';

ExtJS REST client can't get JSON data from the RESTful Services [duplicate]

I implement simple RESTful Service. These are Rest request url and the response json data.
http://localhost:8080/RESTfulTestWeb/rest/services/getJson/aupres
{"id":"aupres","passwd":"aaa","age":45,"name":"joseph"}
The problem is ExtJS Store object client can not handle the above json data. These are ExtJS client codes
Ext.define('extjs.model.Member', {
extend: 'Ext.data.Model',
fields : [{
name : 'id',
type : 'string'
}, {
name : 'passwd',
type : 'string'
}, {
name : 'age',
type : 'int'
}, {
name : 'name',
type : 'string'
}]
});
Ext.onReady(function () {
var members = Ext.create('Ext.data.Store', {
model : 'extjs.model.Member',
//autoLoad : true,
proxy: {
type: 'rest',
url : 'http://localhost:8080/RESTfulTestWeb/rest/services/getJson/aupres',
reader: {
type: 'json',
root: 'id',
},
writer: {
type: 'json'
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
})
}
}
},
listeners: {
load: function(members, operation, success) {
if(success) {
alert('response : ' + members.model.length)
} else {
alert('it failed')
}
}
}
})
var onButtonClick = function() {
members.load()
}
The respose is shown like below
"response : 0"
It seems my ExtJS codes fail to contain the json data.
The rest proxy reader in ExtJs 5 and up looks for a rootProperty: instead of root:.
HI You can overwrite toString() method of your class . then you can get exact.
Like you want data on ["id":"aupres","passwd":"aaa","age":45,"name":"joseph"}]
or some other format

Jasper Async Report - Empty, why?

Lets start , firstly I get parameters for specific report for exmaple
var config = {
url : "http://exmaple.com/jasperserver/rest_v2/reports/reportFolder/exampleReport/inputControls",
method: "GET",
headers: {
Accept: "application/json;"
},
}
Everything is ok, I get a response with an array of inputs,
The array contains, 2 objects with :
First:
{
description: "Date_from",
id: "Date_from",
label: "Date from",
type: "singleValueDate"
}
Second:
{
description: "Date_to",
id: "Date_to",
label: "Date_to",
type: "singleValueDate"
}
Both inputs have a property:
validationRules[0].dateTimeFormatValidationRule.format = "yyyy-MM-dd"
So now I want to run a async report (I will pass async parameter false for now, se there is less code here)
var params ={
reportUnitUri: "/reportFolder/exampleReport",
outputFormat: "html",
freshData : true,
saveDataSnapshot : false,
ignorePagination: true,
async : false,
interactive: false,
allowInlineScripts: true,
parameters: {
"Date_from":["2014-08-01"],
"Date_to":["2015-10-08"]
}
}
So now I try to generate async report:
var config = {
url : "http://exmaple.com/jasperserver/rest_v2/reportExecutions",
headers: {
Accept: "application/json"
},
data: params,
method: "POST"
}
I get a success response, but
totalPages: 0,
requestId: "0200cf28-300f-4e76-b99e-e479be4980ba",
reportURI: "/reportFolder/exampleReport/",
status: "ready",
exports[0].id: "c9a5578a-6bc8-4c3e-8a78-9056ef19f456",
exports[0].status: "ready",
exports[0].outputResource :{
contentType: "text/html",
outputFinal: true
}
When I try to get the output of the report by calling :
http://exmaple.com/jasperserver/rest_v2/reportExecutions/0200cf28-300f-4e76-b99e-e479be4980ba/exports/c9a5578a-6bc8-4c3e-8a78-9056ef19f456/outputResource
The report is empty.
Runing the same via :
http://exmaple.com/jasperserver/rest_v2/reports/reportFolder/exampleReport.html?Date_from=2014-08-01&Date_to=2015-09-08
Gives me a filled report,
Can anyone point me what I'm doing wrong ? :/
I'm pretty sure that it may be something wrong with the parameters but I tried in various ways and I can't find a solution by myself :/
The thing was that the parameters passed to the async report were badly formatted, it should be like this:
parameters: {
reportParameter: [
{name : "Date_from",value : ["2014-08-01"]},
{name : "Date_to",value : ["2015-10-08"]}
]
}

How to read extra properties from model store EXTJs?

​Json reader in is defined for the store as follows:
Ext.define('App.store.MyList', {
extend : 'Ext.data.Store',
model : 'App.model.MyList',
pageSize : 100,
proxy : {
type : 'ajax',
actionMethods : {
create : 'POST',
read : 'POST',
update : 'POST',
destroy : 'POST'
},
root : 'results',
url : 'aaa.htm',
reader : {
type : 'json',
root : 'results',
totalProperty: 'totalCount',
extraProperty: 'abcd'
},
simpleSortMode : true
}
});
How do I read extra property outside the root? I tried to put one inside the reader, it did not work.
try this
grid.getStore().getProxy().getReader().extraProperty

Categories

Resources