Error JSONP Store - jsonp

I am retrieving information for a List via JSONP and am getting the following error in console browser: "unexpected token : "
My store:
Ext.define ('Projeto.store.Mural', {
extend 'Ext.data.Store'
requires: [
'Projeto.model.Mural'
]
config: {
autoLoad: true,
model: 'Projeto.model.Mural'
storeId 'MuralStore'
Proxy {
type: 'jsonp'
url: 'http://URL/mural'
reader: {
type: 'json',
rootProperty: 'rows'
}
}
}
});
My List:
Ext.define ('Projeto.view.MuralList', {
extend 'Ext.dataview.List'
alias: 'widget.murallist'
config: {
loadingText: 'Loading ...',
store: 'MuralStore'
itemTpl: [
'<div> Message: {message} </ div>
]
}
});
JSON returns my URL:
{
"rows": [
{
"lookup": "yyyy"
"dateTime", "10/10/1970"
"id": "1",
"message": "yyyy"
}
{
"lookup": "dsdfasfsadf"
"dateTime", "15/05/2012"
"id": "2",
"message": "dsdfasfsadf"
}
]
}
Does anyone know why the error, because JSON is in a valid format.
Thank you.

You're missing a comma in the middle :
{
"rows": [
{
"lookup": "yyyy"
"dateTime", "10/10/1970"
"id": "1",
"message": "yyyy"
},
{
"lookup": "dsdfasfsadf"
"dateTime", "15/05/2012"
"id": "2",
"message": "dsdfasfsadf"
}
]
}

My guess is that the service you're accessing returns JSON but not JSONP. Search the jsonp tag for "unexpected token". You'll find e.g. Why is this JSONP feed throwing "Unexpected Token" error?

Firstly, You'r missing ':' at many places and also ',' at the end of statements. It always good practise to use : before the property value and , at the end of statement.
Like this,
...
...
requires: [
'Projeto.model.Mural'
],
config: {
autoLoad: true,
model: 'Projeto.model.Mural',
storeId: 'MuralStore',
proxy : {
type:'jsonp',
},
....
....
Secondly, this error is occuring because your response is not a VALID jsonp response.
When I checked on jsonplint.com, it showed me this error
Invalid JSONP
No callback function defined
Improper or no closing
So, either you need to make sure that you have a valid callback function defined.
Otherwise, you could do one thing. Change the type:'jsonp' to type:'ajax' and that should resolve your problem without having to change anything else.

Since you are requesting it as jsonp, not just json, it expects your json to be enclosed in a callback function. Something like:
callback({
"rows": [
{
"lookup": "yyyy"
"dateTime", "10/10/1970"
"id": "1",
"message": "yyyy"
}
{
"lookup": "dsdfasfsadf"
"dateTime", "15/05/2012"
"id": "2",
"message": "dsdfasfsadf"
}
]
})

Related

Facebook ads custom audience Data is missing or does not match schema error

i was building a integration with the facebook ads audience API, and according the documentation the request must be created like this:
POST - https://graph.facebook.com/v15.0/<MY_CUSTOM_AUDIENCE_ID>/users?access_token=<MY_ACCESS_TOKEN>
{
"session":{
"session_id":1,
"batch_seq":1,
"last_batch_flag":true,
"estimated_num_total":1
},
"payload":{
"schema":[
"FN"
],
"data":
[
"8b1ebea129cee0d2ca86be6706cd2dfcf79aaaea259fd0c311bdbf2a192be148"
]
}
}
Using the previus example a received a error 400:
{
"error": {
"message": "(#100) Data is missing or does not match schema",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AqrLd9uIw0D4BBFtHF33bdU"
}
}
For do this i used this documentation https://developers.facebook.com/docs/marketing-api/audiences/guides/custom-audiences#hash
Anyone has use this before?
Your schema field type is array but array use form multi-key qualification.
Change it to string: schema: 'FN'
In docs you can see all formats.
This payload with multi keys work for me:
{
"session": {
"session_id": 123,
"batch_seq": 1,
"last_batch_flag": true
},
"payload": {
"schema": [
"EMAIL",
"PHONE",
"FN"
],
"data": [
["EMAIL_HASH", "PHONE_HASH", "FN_HASH"]
]
}
}

Loopback 4 auto generated model with required id failing validation

I'm using an automated script that runs an auto-generation model using lb4 cli.
Looks like validation expects id to be provided, but swagger missing it in its schema. Why I can't see the id property in swagger?
PLEASE NOTE! I don't want to modify manually my models
lb4 model activity --dataSource DS --table activity
Created model:
export class Activity extends Entity {
#property({
type: 'string',
required: true,
id: 1,
postgresql: {
columnName: 'id',
dataType: 'uuid',
dataLength: null,
dataPrecision: null,
dataScale: null,
nullable: 'NO',
},
})
id: string;
...
}
When I run the swagger tool and try to POST new activity, it missing the id field and returns the following error:
{
"error": {
"statusCode": 422,
"name": "ValidationError",
"message": "The `Activity` instance is not valid. Details: `id` can't be blank (value: undefined).",
"details": {
"context": "Activity",
"codes": {
"id": [
"presence"
]
},
"messages": {
"id": [
"can't be blank"
]
}
}
}
}
If I add a property id manually, then it throws a validation error:
{
"error": {
"statusCode": 422,
"name": "UnprocessableEntityError",
"message": "The request body is invalid. See error object `details` property for more info.",
"code": "VALIDATION_FAILED",
"details": [
{
"path": "",
"code": "additionalProperties",
"message": "must NOT have additional properties",
"info": {
"additionalProperty": "id"
}
}
]
}
}
Change your #model() by #model({settings: {strict: false}}) and add this line [prop: string]: any; into your model
#model({settings: {strict: false}})
[prop: string]: any;

AppSync request mapping template errors not logged in CloudWatch

Crosspost from: https://repost.aws/questions/QUp5jDZ6bsRkeXhIwHgQaWkg/app-sync-request-mapping-template-errors-not-logged-in-cloud-watch
I have a simple resolver that has a simple Lambda function as a data source. This function always throws an error (to test out logging).
The resolver has request mapping template enabled and it is configured as follows:
$util.error("request mapping error 1")
The API has logging configured to be as verbose as possible yet I cannot see this request mapping error 1 from my CloudWatch logs in RequestMapping log type:
{
"logType": "RequestMapping",
"path": [
"singlePost"
],
"fieldName": "singlePost",
"resolverArn": "xxx",
"requestId": "bab942c6-9ae7-4771-ba45-7911afd262ac",
"context": {
"arguments": {
"id": "123"
},
"stash": {},
"outErrors": []
},
"fieldInError": false,
"errors": [],
"parentType": "Query",
"graphQLAPIId": "xxx"
}
The error is not completely lost because I can see this error in the query response:
{
"data": {
"singlePost": null
},
"errors": [
{
"path": [
"singlePost"
],
"data": null,
"errorType": null,
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "request mapping error 1"
}
]
}
When I add $util.appendError("append request mapping error 1") to the request mapping template so it looks like this:
$util.appendError("append request mapping error 1")
$util.error("request mapping error 1")
Then the appended error appears in the RequestMapping log type but the errors array is still empty:
{
"logType": "RequestMapping",
"path": [
"singlePost"
],
"fieldName": "singlePost",
"resolverArn": "xxx",
"requestId": "f8eecff9-b211-44b7-8753-6cc6e269c938",
"context": {
"arguments": {
"id": "123"
},
"stash": {},
"outErrors": [
{
"message": "append request mapping error 1"
}
]
},
"fieldInError": false,
"errors": [],
"parentType": "Query",
"graphQLAPIId": "xxx"
}
When I do the same thing with response mapping template then everything works as expected (errors array contains $util.error(message) and outErrors array contains $util.appendError(message) messages.
Is this working as expected so the $util.error(message) will never show up in RequestMapping type CloudWatch logs?
Under what conditions will errors array in RequestMapping log type be populated?
Bonus question: can the errors array contain more than 1 item for either RequestMapping or ResponseMapping log types?

paypal-checkout-component for vue stays in sandbox mode

I'm struggling to go live. It's weird how something works in sandbox mode but then either there is no documented way to switch to production or it just does not work.
So here is what I got:
<template lang="pug">
.paypal
Spinner(:size="8" :thickness="3")
PaypalButtons.buttons(
:env="env"
:style="style"
:createOrder="order"
:onInit="init"
:onClick="validate"
:onApprove="approve"
:onError="error"
)
</template>
<script>
export default {
name: 'PayPal',
props: {
env: {
type: String,
default: 'sandbox',
validator: value => ['sandbox', 'production'].includes(value)
},
},
// ...
}
</script>
I've tried to set the env prop to production and removing it completely. I can not find any documentation on how to set the environment. I must miss something fundamental.
The error:
As I mentioned the sandbox mode works fine, but as soon as I go live (server side using PayPals production URL and client side with the corresponding env prop), I'm getting the following errors
Request
URL: https://www.sandbox.paypal.com/graphql?UpdateClientConfig.
BODY:
{
"query": "\n mutation UpdateClientConfig(\n $orderID : String!,\n $fundingSource : ButtonFundingSourceType!,\n $integrationArtifact : IntegrationArtifactType!,\n $userExperienceFlow : UserExperienceFlowType!,\n $productFlow : ProductFlowType!,\n $buttonSessionID : String\n ) {\n updateClientConfig(\n token: $orderID,\n fundingSource: $fundingSource,\n integrationArtifact: $integrationArtifact,\n userExperienceFlow: $userExperienceFlow,\n productFlow: $productFlow,\n buttonSessionID: $buttonSessionID\n )\n }\n ",
"variables": {
"orderID": "17884710UT885974F",
"fundingSource": "paypal",
"integrationArtifact": "PAYPAL_JS_SDK",
"userExperienceFlow": "INCONTEXT",
"productFlow": "SMART_PAYMENT_BUTTONS"
}
}
Response:
{
"data": {
"updateClientConfig": null
},
"errors": [
{
"_name": "RESOURCE_NOT_FOUND",
"checkpoints": [
"patchClientConfig"
],
"contingency": true,
"data": {
"message": "The specified resource does not exist."
},
"message": "RESOURCE_NOT_FOUND",
"meta": {},
"path": [
"updateClientConfig"
],
"statusCode": 200
}
],
"extensions": {
"correlationId": "464b1d56d4581",
"tracing": {
"duration": 98157194,
"endTime": "2021-09-06T16:29:45.133Z",
"execution": {
"resolvers": [
{
"duration": 96271082,
"fieldName": "updateClientConfig",
"parentType": "Mutation",
"path": [
"updateClientConfig"
],
"returnType": "Boolean",
"startOffset": 1222180
}
]
},
"startTime": "2021-09-06T16:29:45.035Z",
"version": 1
}
}
}
There is another request to https://www.sandbox.paypal.com/graphql?GetCheckoutDetails with a similar response.
As far as I can tell the request URL should not be www.sandbox.paypal...
I have also commented on an existing issue on GitHub, but I believe it will take too long to get an answer that way.
You are using a sandbox client ID.
Change to a live client ID, from an app in the "Live" tab of your Applications in developer.paypal.com

MFP 8 - error parsing JSON object when using MobileFirst Push API

I am getting the following error when I tried to used the push API to send a notification. The JSON object works in version V7.1
{
"code": "FPWSE0011E",
"message": "Bad Request - The JSON validation failed at 'target'.",
"productVersion": "8.0.0.00-20161122-1902"
}
Here is my JSON object
{
"message": {
"alert": "hello"
},
"settings": {
"apns": {
"badge": 1,
"iosActionKey": "Ok",
"payload": {
"messageType": "HELLO",
"detail": "Here's your message details."
},
"sound": "song.mp3"
},
"gcm": {
"payload": {},
"sound": "song.mp3"
}
},
"target": {
"consumerIds": [],
"deviceIds": ["4A1086CF-873A-4404-BE2D-200EA6BDA8AD"],
"platforms": [
"A","G"
]
}
}
I am using the admin RestAPi interface
https://myserver/mfpadmin/management-apis/2.0/runtimes/mfp/notifications/applications/com.myjobs/messages
I followed the format from the documentation
http://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/apiref/r_restapi_send_message_post.html
Thanks for your help
According to the v8.0 documentation only 1 property is allowed in target. In your JSON I see several properties are defined.
See example JSON here: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/#sending-notifications
And as can be seen:
target" : {
// The list below is for demonstration purposes only - per the documentation only 1 target is allowed to be used at a time.
"deviceIds" : [ "MyDeviceId1", ... ],
"platforms" : [ "A,G", ... ],
"tagNames" : [ "Gold", ... ],
"userIds" : [ "MyUserId", ... ],
},