Why does this fetch request not work with the provided body - javascript

Following this documentation https://docs.tcgplayer.com/reference/catalog_getcategories
I have been able to generate a fetch request to get category search manifest from the endpoint. https://docs.tcgplayer.com/reference/catalog_getcategorysearchmanifest
However I am having trouble with this request https://docs.tcgplayer.com/reference/catalog_searchcategory
specifically the body portion. In my local project I am either getting an error "missing body" or when the body is attached "ops something when wrong" I believe that I am following all of the specifications provided in their documentation.
Here is a code snip of the working request and then one that I am having issues with, although the second request just seems to log and empty array in this environment. https://codesandbox.io/s/romantic-khorana-9tcez5?file=/src/App.js
I have been able to get https://docs.tcgplayer.com/reference/catalog_searchcategory to work with Thunderbolt Client vscode extension using this as a body
{
"sort": "ProductName ASC",
"limit": 500,
"offset": 0,
"filters": [
{
"name": "ProductName",
"values": ["Black"]
},
{
"name": "Rarity",
"values": ["T"]
}
]
}

Related

Facebook open graph doesn't return any instagram media

I have opened this as a bug with facebook here https://developers.facebook.com/bugs/105273653568982/
but thought I would ask here as well to see if anyone else has a solution:
The facebook open graph API says it is supposed to work for instagram as well as facebook, however when used from my server side code OR from the open graph explorer OR from postman, is only returning facebook media items, not instagram media items.
Eg a GET request for comments on my own facebook photo returns successfully:
Request:
https://developers.facebook.com/tools/explorer?method=GET&path=101205943227587%2Fcomments&version=v2.11&access_token=MYACCESSTOKEN
Result:
{
"data": [
{
"created_time": "2016-01-04T16:11:07+0000",
"message": "People might be abl",
"id": "101205943227587_1187008471313990"
}
],
"paging": {
"cursors": {
"before":"WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEU0TnpBd09EUTNNVE14TXprNU1Eb3hORFV4T1RJek9EWTQZD","after":"WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEU0TnpBd09EUTNNVE14TXprNU1Eb3hORFV4T1RJek9EWTQZD"
}
}
}
whereas endeavouring to get the same thing for an instagram post (again using my own media) doesn't work.
Request:
https://developers.facebook.com/tools/explorer?method=GET&path=1531969816055084767%2Fcomments&version=v2.11&access_token=MYACCESSTOKEN
Result:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist:
1531969816055084767",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "D2xUM/kQWsJ"
}
}
None of the methods here
https://developers.facebook.com/docs/instagram-api/overview/
work for instagram media, eg attempting to get the info about Instagram's own account
GET graph.facebook.com
/25025320?fields=biography,id,username,website&access_token=MYACCESSTOKEN
returns an error
{
"error": {
"message": "Unsupported get request. Object with ID '25025320' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "DCreoeyTARt"
}
}
My app has been approved to use the new api with the instagram_basic and instagram_manage_comments permissions, and I know the access token is valid as I am able to get facebook media and use the graph.facebook.com/me api so not sure why all instagram-related stuff is failing.

Cannot Send Mandrill Handlebars Template API

I am trying to access a Mandrill template which I made using their template builder in the Mandrill app (mandrillapp.com/templates).
As I read their documentation I am led to make an Ajax call as such:
{
"key": "<my api key>",
"template_name": "<my template name as defined in Mandrill templates>",
"template_content":[],
"message": {
"from_email": "<my from email>",
"to": <[an array of emails defined above]>,
"subject": "<my subject>",
"merge":true,
"global_merge_vars":[
{
"name": "visitorFirst",
"content": visitorFirst
},
"name": "visitorLast",
"content": visitorLast
},
{
"name": "visitorEmail",
"content": visitorEmail
}
]
}
This returns a 500 error. When I put the content inside "template_content" (which documentation says not to do for handlebars, it at least sends, but does not fill any of the merge variables. I have already set Mandrill to expect Handlebars, not Mailchimp variables.
What am I doing wrong?
Change
"template_content":[]
To
"template_content":null
Problem solved.

Google People API get contacts emails

I need to get contacts emails with Google People API, but can't find a way to do it in docs. Currently I'm making the following request:
request.get('https://people.googleapis.com/v1/people/me/connections?access_token=tokenHere',
function (error, response, body) {
console.log(body);
});
And getting the following responce (I pin only the part of it, for example):
{
"resourceName": "people/c1705421824339784415",
"etag": "328OLZwdaiQ=",
"metadata": {
"sources": [
{
"type": "CONTACT",
"id": "17aae01d0ff8b2df",
"etag": "#328OLZwdaiQ="
}
],
"objectType": "PERSON"
},
"names": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "17aae01d0ff8b2df"
}
},
"displayName": "testGoogleContact",
"givenName": "testGoogleContact",
"displayNameLastFirst": "testGoogleContact"
}
]
}
To achieve this you need to use the Google Plus API: This is what I found on the Google Plus API Documentation page:
You can get an email address for the authenticated user by using the
email scope.
The following JavaScript code example demonstrates how to:
Use Google+ Sign-In to authenticate the user and get a valid OAuth 2.0
access token.
Use the token to make an HTTP GET request to the
https://www.googleapis.com/plus/v1/people/me
REST endpoint. Parse the response and display the user's email
address.
The JSON should like something like this:
{"kind":"plus#person","etag":"\"xw0en60W6-NurXn4VBU-CMjSPEw/mjjYoraGfq3Wi-8Nee4F3k7GYrs\"","emails":[{"value":"**EMAIL**","type":"account"}],"objectType":"person","id":"Person ID","displayName":"FULL NAME","name":{"familyName":"LAST NAME","givenName":"NAME"},"url":"https://plus.google.com/USER","image":{"url":"https://lh5.googleusercontent.com/-RTcRn6jTuoI/AAAAAAAAAAI/AAAAAAAAEpg/Y6cMxfwtbQ4/photo.jpg?sz=50","isDefault":false},"placesLived":[{"value":"CITY","primary":true}],"isPlusUser":true,"verified":false,"cover":{"layout":"banner","coverPhoto":{"url":"https://lh3.googleusercontent.com/SybH-BjYW2ft1rzayamGLg_VwW7ocgnQ5cAxH3ROEpODvyaEODpYKW55gmAxCXDUvfKggQ4=s630-fcrop64=1,00002778ffffffff","height":626,"width":940},"coverInfo":{"topImageOffset":0,"leftImageOffset":0}},"result":{"kind":"plus#person","etag":"\"xw0en60W6-NurXn4VBU-CMjSPEw/mjjYoraGfq3Wi-8Nee4F3k7GYrs\"","emails":[{"value":"**EMAIL HERE**","type":"account"}],"objectType":"person","id":"116508277095473789406","displayName":"FULL NAME","name":{"familyName":"LAST NAME","givenName":"NAME"},"url":"https://plus.google.com/USER","image":{"url":"https://lh5.googleusercontent.com/-RTcRn6jTuoI/AAAAAAAAAAI/AAAAAAAAEpg/Y6cMxfwtbQ4/photo.jpg?sz=50","isDefault":false},"placesLived":[{"value":"CITY I LIVE","primary":true}],"isPlusUser":true,"verified":false,"cover":{"layout":"banner","coverPhoto":{"url":"https://lh3.googleusercontent.com/SybH-BjYW2ft1rzayamGLg_VwW7ocgnQ5cAxH3ROEpODvyaEODpYKW55gmAxCXDUvfKggQ4=s630-fcrop64=1,00002778ffffffff","height":626,"width":940},"coverInfo":{"topImageOffset":0,"leftImageOffset":0}}}}
Source: Google Plus API documentation
In case anyone else comes across this question: the solution to retrieving the email addresses of an authorized user's contacts, what the OP seems to want (not the authorized user's own email address) is at Why can't I retrieve emails addresses and phone numbers with Google People API?.
Explanation: If you look at the section under "Query Parameters" on https://developers.google.com/people/api/rest/v1/people.connections/list, you'll see that requestMask is a parameter (documented at https://developers.google.com/people/api/rest/v1/RequestMask).
It says that you'll need to include the requestMask parameter in your query, because you're doing a people.list query (i.e. using the connections GET endpoint). The requestMask parameter basically tells the API what fields to pull: person.emailAddresses tells it to pull the peoples' email addresses, person.emailAddresses,person.names tells it to pull their email addresses and names, etc.
GET https://people.googleapis.com/v1/people/me/connections?sortOrder=FIRST_NAME_ASCENDING&fields=connections(emailAddresses%2Cnames)&key={YOUR_API_KEY}
Try this and it will give you the emails. Make sure your contacts has emails.
You can get the profile emails from the Google People API, by making a request to https://people.googleapis.com/v1/people/me.
If you want non public emails, you will need to request the email or https://www.googleapis.com/auth/user.emails.read scope as specified in https://developers.google.com/people/v1/how-tos/authorizing#profile-scopes

JavaScript request connection with data

I have a task to create javascript realtime app. Server side is ready (wss://), I have to create client-side.
The main tasks I have problems with:
The client can ping the server to check your connectivity. Client does a ping, including the sequence number (which allows to trace the exact ping duration).
{
"$type": "ping",
"seq": 1
}
server will respond:
{
"$type": "pong",
"seq": 1
}
Client request
{
"$type": "subscribe_tables"
}
Server will respond with the list of tables, and update the client with table_added, table_removed and table_updated messages whenever the status has changed.
{
"$type": "table_list",
"tables": [
{
"id": 1,
"name": "table 1",
"description" : "one, two"
}, {
"id": 2,
"name": "table 2"
"description" : "two, three"
}
]
}
table_updated event
{
"$type": "update_table",
"table": {
"id": 3,
"name": "table - Foo Fighters",
"participants": 4
}
}
Question: I know, that I can use new EventSource(), is this correct? How can I send data $type, for example with it?
I know, that I can use new EventSource(), is this correct? How can I
send data $type, for example with it?
No, that is not correct. If your server is expecting a webSocket connection, then you use new WebSocket(...) from the client to make the connection from client to server. And EventSource() object is used for server-side events which is a completely different transport from webSocket.
You can see programming examples here on MDN for using webSocket.
Also, if you are trying to send Javascript objects as data, you would typically use JSON.stringify() to serialize them into a string and then send that and then on the receiving end, you would use JSON.parse() to parse the JSON string back into a Javascript object. That's how you would send info like your $type along with other data in the same message.
FYI, socket.io is a library built on top of webSocket that has become very popular because it does a lot of things for your automatically that are typically needed in webSocket programming such as JSON serialization, automatic reconnect, automatic keep alive, connection drop detection, etc... You certainly don't have to use it in client and server, but it often saves a lot of time.

Google Developer OAuth Consent: The supplied API key is not configured for use from this referrer

I'm trying to play around a little bit with the Google Calendar API but I can't create a OAuth ID ( as mentioned in this example: Google Calendar JS API.
I created a project, clicked Cerdentials and if you try to create an OAutho-client-Id you will be forwarded to the configure consent tab.
Here you have to enter your email address (is standard google account) and a project name. Then pressing save leads to an error:
{
"error": {
"code": 403,
"message": "The supplied API key is not configured for use from this referrer.",
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/648364020234/apiui/credential"
}
]
}
]
}
}
The URL metioned in this JSON I can't access (no rights).
What can I do to get a simple oAuth ID?
Tried with several new projects, other naming of the consent projet name.
Also tried to create an API key which can be referred by all clients (empty field).
Any ideas anybody?

Categories

Resources