MailChimp API 3.0 batch request returns 400 Invalid Resource error - mailchimp

I've been trying to use the batch endpoint of MailChimp API (version 3.0) to subscribe new users to a list, but can't make it work.
Here is the request:
POST /3.0/batches
{
"operations": [
{
"method" : "POST",
"path" : "lists/c852ce5c86/members",
"body": "{\"email_address\":\"email#domain.tld\", \"status\":\"subscribed\"}"
}
]
}
The request seems ok cause I get a 200 response:
{
"id": "49abca6ef3",
"status": "finished",
"total_operations": 1,
"finished_operations": 1,
"errored_operations": 1,
"submitted_at": "2015-09-21T18:11:16+00:00",
"completed_at": "2015-09-21T18:11:23+00:00",
"response_body_url": "https://mailchimp-api-batch.s3.amazonaws.com/49abca6ef3-response.tar.gz?..."
}
However, as you can see, the only operation in my batch is errored.
Here is the response_body_url for this operation:
[{
"status_code":400,
"operation_id":null,
"response":"{
\"type\":\"http://kb.mailchimp.com/api/error-docs/400-invalid-resource\",
\"title\":\"Invalid Resource\",
\"status\":400,
\"detail\":\"The resource submitted could not be validated. For field-specific details, see the 'errors' array.\",
\"instance\":\"\",
\"errors\":[{
\"field\":\"\",
\"message\":\"Schema describes object, NULL found instead\"
}]
}"
}]
which is not very helpful :(
Note that if I directly hit POST lists/c852ce5c86/members with {"email_address":"email#domain.tld", "status":"subscribed"} payload, it's working properly.

That was actually a bug in the mailchimp API. After reaching them they quickly fixed it.

Related

Problem with create team with Microsoft Graph Api

I have a problem with creating teams using the Microsoft Graph Api. I can get/create groups but when I try to get/create teams I get an error. I'm using postman and the group has owners and members, just as the documentation of MS, also has the permissitions it asks for groups. If somebody can help me, cause I look everywhere for a same error but no found it.
PUT https://graph.microsoft.com/v1.0/groups/{id}/team
Headers: Authorization: bearer token and content-type: json
Body is
{
"memberSettings": {
"allowCreateUpdateChannels": true
},
"messagingSettings": {
"allowUserEditMessages": true,
"allowUserDeleteMessages": true
},
"funSettings": {
"allowGiphy": true,
"giphyContentRating": "strict"
}
}
I always get the same error
{
"error": {
"code": "BadGateway",
"message": "Failed to execute backend request.",
"innerError": {
"request-id": "45eeba8a-9d35-45e8-b42e-c60da7a47dde",
"date": "2020-01-23T21:55:44"
}
}
}
According to the Graph API docs for this, you're not calling the correct endpoint to create a new Team. It should be
POST https://graph.microsoft.com/beta/teams
and a payload similar to
Content-Type: application/json
{
"template#odata.bind": "https://graph.microsoft.com/beta/teamsTemplates('standard')",
"displayName": "My Sample Team",
"description": "My Sample Team’s Description",
"owners#odata.bind": [
"https://graph.microsoft.com/beta/users('userId')"
]
}
Note that it's slightly different, as per the docs, whether you're using delegated versus application permissons.

Google Speech API: the requested URL was not found on this server

I am attempting some simple tests on the Google Speech API, and when my server makes a request to this url (below), I get the 404. that's an error response. Not sure why.
https://speech.googleapis.com/v1/speech:recognize?key=[MY_API_KEY]
The body of my request looks like this:
{
"config": {
"languageCode": "en-US",
"encoding": "LINEAR16",
"sampleRateHertz": 16000,
"enableWordTimeOffsets": true,
"speechContexts": [{
"phrases": ["Some", "Helpful", "Phrases"]
}]
},
"audio":{
"uri":"gs://mydomain.com/my_file.mp3"
}
}
And here is the response:
As you can see, that is a valid resource path, unless I'm totally mistaken about something (I'm sure I am): https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/recognize
Update 1:, Whenever I try this with the Google API explorer tool, I get this quota exceeded message (even though I have not yet issued a successful request to the API).
{
"error": {
"code": 429,
"message": "Quota exceeded for quota metric 'speech.googleapis.com/default_requests' and limit 'DefaultRequestsPerMinutePerProject' of service 'speech.googleapis.com' for consumer '[MY_API_KEY]'.",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/[my_project_id]/apiui/credential"
}
]
}
]
}
}
Update 2: Interestingly, I was able to get some 200 ok's using the Restlet client, but even in those cases, the response body is empty (see screenshot below)
I have made a test by using the exact URL and Body content you added to the post, however, I was able to execute the API call correctly.
I noticed that if I add some extra character to the URL, it fails with the same 400 error since it doesn't exist. I would suggest you to verify that the URL of your request doesn't contain a typo and that the client you use is executing the API call correctly. Also, ensure that your calling code is not encoding the url, which could cause issues given the colon : that appears in the url.
I recommend you to perform this test by using the Try this API tool directly or Restlet client which are the ones that I used to replicate this scenario.

GoCardless API using Classic ASP

I'm creating the following request in vbscript and sending to the gocardless sandbox:
url="https://api-sandbox.gocardless.com/"
typ="GET"
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open typ, url, False
xml.setRequestHeader "Authorization", "Bearer " & GCAccessToken
xml.SetRequestHeader "GoCardless-Version", "2015-07-06"
xml.SetRequestHeader "Accept","application/json"
xml.SetRequestHeader "Content-Type", "application/json"
xml.Send
GetGC = xml.responseText
Set xml = Nothing
The response I always get despite any tweaks I do is:
{"error":{"message":"not found","errors":[{"reason":"not_found","message":"not found"}],"documentation_url":"https://developer.gocardless.com/api-reference#not_found","type":"invalid_api_usage","request_id":"0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009","code":404}}
Any help would be appreciated. Have successfully done similar for Stripe but now need to use GC.
If you read the response from the API
{
"error": {
"message": "not found",
"errors": [{
"reason": "not_found",
"message": "not found"
}
],
"documentation_url": "https://developer.gocardless.com/api-reference#not_found",
"type": "invalid_api_usage",
"request_id": "0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009",
"code": 404
}
}
The error appears to be a HTTP status code (as is common with RESTful APIs) - 404 Not Foundlooking at the documentation link provided in the response;
404
Not Found. The requested resource was not found or the authenticated user cannot access the resource. The response body will explain which resource was not found.
So the issue could be;
You have failed to authenticate using the token in the code provided.
You authenticated but don't have permission to access the resource.
The resource you are looking for does not exist.
In this particular instance, I would suggest it is because the resource doesn't exist as the code doesn't specify a resource, only the base URL of the API which won't constitute an API endpoint you can interact with.
Looking at the documentation it's clear you need to provide a valid endpoint in the URL, at the time of writing there are 15 core endpoints to interact with along with 2 helper endpoints.
For example, a create payment request/response would look like;
POST https://api.gocardless.com/payments HTTP/1.1
{
"payments": {
"amount": 100,
"currency": "GBP",
"charge_date": "2014-05-19",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"links": {
"mandate": "MD123"
}
}
}
HTTP/1.1 201 (Created)
Location: /payments/PM123
{
"payments": {
"id": "PM123",
"created_at": "2014-05-08T17:01:06.000Z",
"charge_date": "2014-05-21",
"amount": 100,
"description": null,
"currency": "GBP",
"status": "pending_submission",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"amount_refunded": 0,
"links": {
"mandate": "MD123",
"creditor": "CR123"
}
}
}
Unfortunately, the code sample provided in the question doesn't really do anything so it's difficult to suggest what you are trying to do. In conclusion, I would suggest re-visiting the documentation for the API and look through the samples provided.

google speech api response is empty, even with this example test

When I run the API explorer from this page i get a 200 OK response, but the response json doesn't have any transcription. What am i doing wrong?
API Explorer location:
https://cloud.google.com/speech/reference/rest/v1/speech/longrunningrecognize
Request parameters:
Default
Request body:
{
"config": {
"encoding": "FLAC",
"languageCode": "en-US",
"sampleRateHertz": 16000
},
"audio": {
"uri": "gs://cloud-samples-tests/speech/brooklyn.flac"
}
}
Response:
{
"name": "3497944051092250866"
}
i figured it out.
with longrunningrecognize you get back the name object and then you have to send a operations.get to retrieve your processed object.
this is explained here beautifully
https://medium.com/towards-data-science/tutorial-asynchronous-speech-recognition-in-python-b1215d501c64

403 Forbidden resposnse from a GET request to http://api.espn.com/v1/sports/news/6277112

I have problem with the ESPN API:
I have an API key, and sent a query to the address http://api.espn.com/v1/sports/news/1581816?region=GB, which included my API key in the parameters.
I received 403 forbidden response: with this JSON
{
"status": "error",
"code": 403,
"message" : "Account Inactive"
}
I am looking at http://developer.espn.com/docs/headlines#using-the-api and at the last line it says that i can make a GET request to this url and it should work, but it doesn't.
How can I receive a valid response from the ESPN servers?
I just test it and it works fine. That means your key is invalid, or you are not including it. Replace below and it will work.
http://api.espn.com/v1/sports/news/1581816?region=GB&apikey=<yourKey>
--
{
timestamp: "2013-10-13T15:33:49Z",
resultsOffset: 0,
status: "success",
resultsLimit: 10,
resultsCount: 1,
headlines: [
{ ... }
]
}

Resources