Parse Cloud Hosting Truncating User Results - express

I'm having a strange issue with Parse's Cloud Hosting platform. I have a route that displays info on all 'Providers' in my system. A Provider has a column that is a Pointer to a User object. This is a special Parse.User object.
My goal is to get all Providers and the User info that the provider points to. Seems simple, using the "include" method for the query.
The route code looks like this:
exports.index = function(req, res) {
var providersQuery = new Parse.Query('Provider');
providersQuery.include('user');
providersQuery.find().then(function(providers) {
console.log(providers); //for debugging
res.render('providers/index', { providers: providers });
});
};
Here's where things get weird. The above log statement shows all Providers with all the User data included:
[{ "address": "123 Main St.", "city": "Anytown", "zip": "77777",
"user":
{ "email": "john.smith#example.com", "firstName": "John", "lastName": "Smith", "objectId": "abcd123", "__type": "Object", "className": "_User" }
}]
Notice that the __type is "Object".
However, in my view the User object data is truncated and only shows __type, className, and objectId fields:
//index.ejs
<%- JSON.stringify(providers) %>
Results in the following:
[{ "address": "123 Main St.", "city": "Anytown", "zip": "77777",
"user":
{ "objectId": "abcd123", "__type": "Pointer", "className": "_User" }
}]
All the info about the user is gone!! And the __type is now "Pointer". What the hell is going on?

Apparently calling JSON.stringify on Parse object will return "included" objects back to their "Pointer" selves. I'm sure there is some good reason for this, but it's certainly inconvenient.

Related

Zoho Recruit API Register / Login Candidate

Could someone guide me an idea of how to create the registration and login for candidates with the Recruit api? I'm making a flutter app and I need my candidates to register and log in trow the app and see the job opening, post jobs.
At the moment I created the user with [POST] https://recruit.zoho.com/recruit/v2/Candidates
{
"data": [
{
"Email": "mail#gmail.com",
"First_Name": "TheName",
"Last_Name": "TheLastName",
"Mobile": "000000000",
"Expected_Salary": "8000000",
"Country": "PY",
"Departamento": "Central",
"C_I": "37114594",
"Ciudad_de_residencia": "City",
"$Password":"myPassWord199**"
}
],
"trigger": [
"approval",
"workflow",
"blueprint"
]
}
Works Well, got success
{
"data": [
{
"code": "SUCCESS",
"details": {
"Modified_Time": "2022-06-15T20:47:23-04:00",
"Modified_By": {
"name": "Admin",
"id": "00000000000000"
},
"Created_Time": "2022-06-15T20:47:23-04:00",
"id": "00000000000000",
"Created_By": {
"name": "Admin",
"id": "00000000000000"
}
},
"message": "record added",
"status": "success"
}
]
}
But If I try to log in in the web version (for testing the new candidate) don't work, but if it see the dashboard, the user exist. Need to add something else?
Basically I need a register api and a login one for the created record of the candidate.
Any help will be awesome, Thanks

Mulitpart forms and nested objects Insomnia REST client

So I've decided to switch to Insomnia from Postman, as for some reason my Postman app keeps hanging. Everything is going well but I'm having trouble using multipart forms with Insomnia. How would I access this in Insomnia? In Postman I just need to put profile{location} as the field and it works, but Insomnia gives me an error of can't read property '0' of undefined
The object is structured as follows
{
"id": "5e76dd60d49dfd6827688908",
"username": "TLCFan",
"email": "tlc#fan.com",
"profile": {
"avatar": {
"url": "/static/img/defaultAvatar.png"
},
"header": {
"url": "/static/img/defaultBG.png"
},
"forHire": false,
"location": "Bimingham",
"bio": "Design is my life, but this is my story"
}
}

Not Found error when charging Square API

The Square REST API docs state that I should get a list of my locations and then use a returned location code when I call the transactions endpoint (to charge a credit card). I am doing exactly this but the returned error says that the merchant has no location with the supplied ID.
I have tried this with and without the location_id in the JSON sent to the transactions endpoint, since it is a path variable. Same result. I have also seen on Square's API FAQ that the usual cause of a 404 not found is the card nonce being created wrong, but this response clearly says the location ID is not valid.
I have tested this with Postman and JSON and I can see that the location code is correct. Here are my calls and the responses:
This is a GET request:
https://connect.squareup.com/v2/locations
And here is the response:
{
"locations": [
{
"id": "FPVPFZ4DXXXXX",
"name": "MyCompany",
"address": {
"address_line_1": "123 Candy Lane",
"address_line_2": "",
"locality": "Smithfield",
"administrative_district_level_1": "RI",
"postal_code": "02917",
"country": "US"
},
"timezone": "America/Los_Angeles",
"capabilities": [
"CREDIT_CARD_PROCESSING"
]
},
{
"id": "4FHNAN1WXXXXX",
"name": "MyCompany2",
"address": {
"address_line_1": "567 Smith Street",
"address_line_2": "",
"locality": "Greenville",
"administrative_district_level_1": "RI",
"postal_code": "02828-2910",
"country": "US"
},
"timezone": "America/Los_Angeles",
"capabilities": [
"CREDIT_CARD_PROCESSING"
]
}
]
}
I modified the returned IDs a bit in the above example.
Next I make a call to charge a card to this uri:
https://connect.squareup.com/v2/locations/FPVPFZ4DXXXXX/transactions
With this body:
{
"note":"",
"idempotency_key":"azsxdcfvrtrewsdf",
"location_id":"FPVPFZ4DXXXXX",
"shipping_address":{
"address_line_1":"123 My Street",
"address_line_2":null,
"locality":"Greenville",
"administrative_district_level_1":"RI",
"postal_code":"02828",
"country":"US"
},
"billing_address":{
"address_line_1":"123 My Street",
"address_line_2":null,
"locality":"Greenville",
"administrative_district_level_1":"RI",
"postal_code":"02828",
"country":"US"
},
"card_nonce":"CBASEPPW7fjdUHe-3jP6ZZ4kvE0gAQ",
"reference_id":"RT-12345678",
"amount_money":{
"amount":12500,
"currency":"USD"
},
"delay_capture":true,
"buyer_email_address":"jim#xxxxxxxxxx.net",
"customer_id":"JIM"
}
And I get this response:
{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "NOT_FOUND",
"detail": "This merchant does not have a location with the ID `FPVPFZ4DXXXXX`.",
"field": "location_id"
}
]
}
So the location ID matches exactly the ID returned by the locations endpoint.
Can someone familiar with this API help me out? Square's docs and support is sadly lacking.
I think the issue here is that you have tried to use your sandbox credentials (sandbox-sq0idp-defoUOlu...) to charge against your production location FPVPFZXXXXX. If you call ListLocations with your sandbox credentials, you should get a different location that you can then do sandbox charges with.

Update Account (PUT) Endpoint in new Yodlee API for MFA

Background
I am using the newer Yodlee Aggregation API that differs from what I was previously building off of.
I am currently using this endpoint in the account registration flow to put the MFA response:
PUT /{cobrandName}/v1/providers/{providerAccountId}
My request looks like this:
{
url: `${this.rest}providers/${providerAccountId}`,
headers: {
'Authorization': `cobSession=${self.appToken}, userSession=${token}`
},
form: {
'MFAChallenge': JSON.stringify(newMfa)
}
}
where this.rest is my personal rest url, providerAccountId is the appropriate providerAccountId for the refresh, self.appToken is the current cobrand session token, token is the current user's login token, and newMfa is a JSON object being stringified that matches this profile:
{
"loginForm": {
"mfaTimeout": 94650,
"formType": "questionAndAnswer",
"row": [
{
"id": "SQandA--QUESTION_1--Row--1",
"fieldRowChoice": "0001",
"form": "0001",
"label": "What is the name of your state?",
"field": [
{
"id": "SQandA_QUESTION_1_1",
"name": "QUESTION_1",
"isOptional": false,
"value": "Enter the answer",
"valueEditable": true,
"type": "text"
}
]
},
{
"id": "SQandA--QUESTION_2--Row--2",
"fieldRowChoice": "0001",
"form": "0001",
"label": "What is the name of your first school",
"field": [
{
"id": "SQandA_QUESTION_2_2",
"name": "QUESTION_2",
"isOptional": false,
"value": "Enter the answer",
"valueEditable": true,
"type": "text"
}
]
}
]
}
with the exeption being the value fields of the field object, which have been encrypted with PKI as per instructions.
Issue
However, when I carry out this PUT request, I get this error from Yodlee:
{ errorCode: 'Y803',
errorMessage: 'MFAChallenge or providerParam required',
referenceCode: 'p1460412835654A4Q24t' }
though I clearly have an MFAChallenge parameter in my form. Any ideas on why I could be getting this error if the MFAChallenge is present (and note that it is the only info that is passed through the PUT request other than through headers or url parameters)? I tried putting it through as body data, but that doesn't seem to work, and very few of the API endpoints actually seem to use body over form encoded strings, though there was at least one.
You have to send this information MFAChallenge as part of URL, see below example
https://developer.api.yodlee.com/ysl/restserver/v1/providers/10114184?MFAChallenge=%7B%20%22loginForm%22%3A%20%7B%20%20%20%20%20%22mfaTimeout%22%3A%2094650%2C%20%20%20%20%20%22formType%22%3A%20%22questionAndAnswer%22%2C%20%20%20%20%20%22row%22%3A%20%5B%20%20%20%20%20%7B%20%20%20%20%20%20%20%20%20%22id%22%3A%20%22SQandA--QUESTION_1--Row--1%22%2C%20%20%20%20%20%20%20%20%20%22fieldRowChoice%22%3A%20%220001%22%2C%20%20%20%20%20%20%20%20%20%22form%22%3A%20%220001%22%2C%20%20%20%20%20%20%20%20%20%22label%22%3A%20%22What%20is%20the%20name%20of%20your%20state%3F%22%2C%20%20%20%20%20%20%20%20%20%22field%22%3A%20%5B%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22id%22%3A%20%22SQandA_QUESTION_1_1%22%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22QUESTION_1%22%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22isOptional%22%3A%20false%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22value%22%3A%20%22Enter%20the%20answer%22%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22valueEditable%22%3A%20true%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22text%22%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%5D%20%20%20%20%20%7D%2C%20%20%20%20%20%7B%20%20%20%20%20%20%20%20%20%22id%22%3A%20%22SQandA--QUESTION_2--Row--2%22%2C%20%20%20%20%20%20%20%20%20%22fieldRowChoice%22%3A%20%220001%22%2C%20%20%20%20%20%20%20%20%20%22form%22%3A%20%220001%22%2C%20%20%20%20%20%20%20%20%20%22label%22%3A%20%22What%20is%20the%20name%20of%20your%20first%20school%22%2C%20%20%20%20%20%20%20%20%20%22field%22%3A%20%5B%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22id%22%3A%20%22SQandA_QUESTION_2_2%22%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22QUESTION_2%22%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22isOptional%22%3A%20false%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22value%22%3A%20%22Enter%20the%20answer%22%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22valueEditable%22%3A%20true%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22text%22%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%5D%20%20%20%20%20%7D%20%5D%20%7D

Using the advanced query api and get all pages back

I can successfully call into an advanced query method and get the first page of data back (using the post option) refernced in http://api.docs.import.io/#QueryMethods
Anyone have an idea how to page after that? I get 20 out of 190 results. My query looks like:
var query = {
"input": { "last_name": name },
"additionalInput": {
"8d817939-my-api-key-9502ed72": cookie
},
"returnPaginationSuggestions": true
}
Where param name and cookie are known vars.
The results do not return a pagination block either as in the model result:
{
"connectorVersionGuid": "string",
"pagination": {
"pattern": "string",
"next": "string",
"currentPageNum": 0,
"previous": "string"
},
"connectorGuid": "string",
"totalResults": 0,
"errorType": "TimeoutException",
"outputProperties": [
{
"type": "STRING",
"name": "string"
}
],
"cookies": [
"string"
],
"results": [
{}
],
"pageUrl": "string",
"error": "string",
"data": {}
}
If the response is not returning the "Pagination" block, it means that the system was not able to identify pagination on a given page.
As far as I remember pagination is flaky for Extractor APIs, while it works quite well for Magic APIs. I would recommend trying to get a Magic extractor, and getting pagination suggestions for it. Than you should be able to get the "Pagination" block in your response, and use "next" value to get the URL of the next page.