Eloqua bulk REST API gives serialization error - rest

I am trying to make bulk REST API call to import data to Eloqua. I am able to make call to GET, But POST gives me "400- There was a Serialization Error".
This is first step to get response for creating import definition from Eloqua Bulk REST.
URL: /api/bulk/2.0/contacts/imports
Headers:
Authorization: valid oAuth2 token
Content-Type: application/json
Body:
{
"name": "AppSource Test",
"fields": {
"firstName": "{{Contact.Field(C_FirstName)}}",
"lastName": "{{Contact.Field(C_LastName)}}",
"emailAddress": "{{Contact.Field(C_EmailAddress)}}"
},
"identifierFieldName": "emailAddress"
}
Documentation also doesn't have details about this.
Am I missing something?

Change Body content type to "raw"
Explanation:
Eloqua expects the data it receives be in "raw" format. Although Header says Content type json, Setting Body as "raw" works.

Related

How to create permission to read/view files?

How do I pass the permissions hash or json? correctly and maybe access token?
https://www.googleapis.com/drive/v3/files/file_id/permissions
This is the body I want
{
"role": "reader",
"type": "user",
"emailAddress": "cratagg#gmail.com"
}
But I don't know how to include it in postman. I've been trying many ways but none seems to work. I couldn't either with the https://developers.google.com/oauthplayground/ - I may not know how to formulate the request.
The only thing that worked was the https://developers.google.com/drive/api/v3/reference/permissions/create "Try this API" section
The Try this API feature shows the HTTP implementation if expanded
So, in your case, the request would be:
POST https://www.googleapis.com/drive/v3/files/[FILEID]/permissions?key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"role": "reader",
"type": "user",
"emailAddress": "cratagg#gmail.com"
}
Whereby you need to specify the API key and the FILEID.

Can apiary.io echo back request data?

If I have an apiary.io API described like this:
### Create a User [POST]
+ Request (application/json; charset=utf-8)
{
"user_id": 1053,
"username": "demo#demo.com",
"email": "demo#demo.com",
"active": "true"
}
+ Response 201 (application/json)
{
"user_id": 1053,
"username": "demo#demo.com",
"email": "demo#demo.com",
"active": "true"
}
When I call it from my application and pass it data, it will always pass me back the described payload no matter what data I pass in.
Is there a way to get it to echo back the exact data that I passed in instead of the described payload?
According to Apiary docs/examples you can not, only static request-response mocking. Also you could track this issue.
If you want to use kind of advanced mocks I would suggest you wiremock. It's not so fancy, but way more feature reach. You could run it as a service and update mock mappings at runtime by sending HTTP requests.
Please check solution for your question using wiremock. Related documentation.

Facebook's Batch Request not picking up a JSON parameter

My goal is to create a number of ads using Facebook's Batch API : https://developers.facebook.com/docs/marketing-api/asyncrequests/v2.9
I am sending a POST request at this URL:
https://graph.facebook.com/v2.9/act_158365238/ads
I am sending 2 parameters as per the documentation:
1- access_token
2- batch
The JSON in the batch parameter looks like :
{
"method": "POST",
"relative_url": "v2.9\/act_158365238\/ads",
"attached_files": "test1",
"body": "creative={\"title\":\"Test title 1\",\"body\":\"Test body 1\",\"object_url\":\"https:\/\/apps.facebook.com\/testapp\/\", \"image_file\":\"test1.jpg\"}&targeting={\"countries\":[\"US\"]}&name=test1"
}
The Problem
When I send this request with POSTman or my PHP code, it throws the following error
{
"error": {
"message": "(#100) The parameter creative is required",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Gj2sG7N8l1f"
}
}
However when I send the exact same request via Facebook's Graph API tool, it successfully creates the ads.
According to the API Documentation provided to create creatives you should be posting to the URL "v2.9/act_187687683/adcreatives"... The fragment of the batch that you are showing is used to create an Ad.
If, as you say, your intention is to create an AdCreative then you should be using something like the above, which differs in the body from what you are using:
{
"method": "POST",
"name": "create_creative",
"relative_url": "v2.9/act_187687683/adcreatives",
"attached_files": "test1",
"body": "title=Test title&body=Test body&link_url=http://www.test12345.com&image_file=test1.jpg"
}
In the other hand, if what you are creating is an add, then you should consider referencing the AdCreative by its ID as is done in the examples, hence in the case of a creative added in the same batch you could use the relative reference to the name:
creative={\"creative_id\":\"{result=create_creative:$.id}\"}
or if it is a creative already created you can reference it by the creative_id:
creative={\"creative_id\":\"123456\"}
I think the message is a red herring -- it's not seeing your body's creative field because the OAuth isn't properly set in your POSTman requests, so it isn't parsing the body or seeing the creative field.
If you don't know how to set OAuth in POSTman, here's a good tutorial:
https://docs.brightcove.com/en/video-cloud/concepts/postman/postman.html

Include default responses to swagger documentation

I am building an application using swagger in python. I specified all outcomes produces by my code in the swagger yaml file. Connexion, the library which I am using, also checks for validity of the data provided by the client and might for example return
{
"detail": "Invalid Content-type (application/json), expected JSON data",
"status": 415,
"title": "Unsupported Media Type",
"type": "about:blank"
}
For the documentation to be complete the ui should consists of all the response messages specified by me and the implicit response messages of connexion.
Is there a way to add all this implicit responses to the swagger-ui?

How to retrieve attachments from Facebook Graph API?

I'm struggling to find a method to retrieve attachments from a message via the Graph API.
When I request the message (m_mid.xxxxxx/attachments), I get the response:
"data": [
{
"id": "105446924xxxxxx",
"mime_type": "application/pdf",
"name": "some.pdf",
"size": 89628
}
]
Any way to get the attachment link or the file itself?
The documentation only lists four fields that you can use as query parameters to filter the results, and these are the same as the response to your request.
However, if you remove the fields parameter from the request, you'll also get an image_data object which includes URLs.
For example:
https://graph.facebook.com/v5.0/{message_id}/attachments?access_token={page_access_token}