I am working this API https://developer-eu.elavon.com/docs/opayo/spec/api-reference-0#operation/createCi.
I faced an issue, when creating card-identifier. I could not get an expected response.
The test API is https://pi-test.sagepay.com/api/v1/card-identifiers
To create a Card Identifier, We need a merchantKey to use as a bearerToken and request body is
{ "cardholderName": "Spongebob Squarepants", "cardNumber": "4929000000006", "expiryDate": "0223", "securityCode": "123" }
To create merchantKey use this https://reqbin.com/pzag38mw
To create Card Identifieruse this https://reqbin.com/zkhuuecs
And I added My postamn request here.
My postman http request for create Card Identifier.
curl --location --request POST 'https://pi-test.sagepay.com/api/v1/card-identifiers' \
--header 'Authorization: Bearer E0780245-2701-4748-924A-A1D5A904EB62' \
--header 'Content-Type: application/json' \
--header 'Cookie: AWSALB=o44OLd5fFLrFUD4meQBU0sxMs64iiql4YlDlppQILCFio+6pOo16e+tLu7SaI+F8sDS8CgSrRTwOcMo//ODTGcJGgNSTHPHxrP5hs87mkM1I1Xos3F0hDEoTD4dV; AWSALBCORS=o44OLd5fFLrFUD4meQBU0sxMs64iiql4YlDlppQILCFio+6pOo16e+tLu7SaI+F8sDS8CgSrRTwOcMo//ODTGcJGgNSTHPHxrP5hs87mkM1I1Xos3F0hDEoTD4dV' \
--data-raw '{
"cardholderName": "Spongebob Squarepants",
"cardNumber": "4929000000006",
"expiryDate": "0223",
"securityCode": "123"
}'
I got this Response
{
"errors": [
{
"description": "Missing mandatory field",
"property": "cardDetails.cardNumber",
"clientMessage": "The card number is required",
"code": 1003
},
{
"description": "Missing mandatory field",
"property": "cardDetails.cardholderName",
"clientMessage": "The cardholder name is required",
"code": 1003
},
{
"description": "Contains invalid value",
"property": "cardDetails.expiryDate",
"clientMessage": "The expiry date is invalid",
"code": 1009
},
{
"description": "Missing mandatory field",
"property": "cardDetails.expiryDate",
"clientMessage": "The expiry date is required",
"code": 1003
}
]
}
But The response sholud be somthing like this:
{
"cardIdentifier": "C6F92981-8C2D-457A-AA1E-16EBCD6D3AC6",
"expiry": "2015-08-11T10:45:16.285Z",
"cardType": "Visa"
}
What is the mistake I did when I sent a post request
Check the method of posting you are using in postman. If you are unsure edit to add a screenshot. Check if you have selected:
As if you use another method it may not read it
So once you have set that instead of sending you data as:
{
"cardholderName": "Spongebob Squarepants",
"cardNumber": "4929000000006",
"expiryDate": "0223",
"securityCode": "123"
}
You should send it as:
{ "cardDetails":
{
"cardholderName": "Spongebob Squarepants",
"cardNumber": "4929000000006",
"expiryDate": "0223",
"securityCode": "123"
}
}
This is because it is asking the data from under cardDetails
Please tick this if it fixed your problem so I know
Related
I am trying to get my Microsoft Teams assignments through Microsoft Graph. I submit this GET request https://graph.microsoft.com/beta/education/me/classes/{id}/assignments as shown in the docs, with my authentication token as a header. However, below is the reply I get. I am doing this with python, however I have also tried from Graph Explorer which yields the same result.
{
"error": {
"code": "InternalServerError",
"message": "Object reference not set to an instance of an object.",
"innerError": {
"date": "2020-09-07T16:44:48",
"request-id": "011086a0-9240-4896-9363-d403a1a0fb05"
}
}
}
Does anybody have any insight? Is this a problem with Microsoft?
You need to remove the /me. The correct URI is https://graph.microsoft.com/beta/education/classes/{id}/assignments.
From the documentation
POST https://graph.microsoft.com/beta/education/classes/11019/assignments
Content-type: application/json
Content-length: 279
{
"dueDateTime": "2014-02-01T00:00:00Z",
"displayName": "Midterm 1",
"instructions": {
"contentType": "text",
"content": "Read chapters 1 through 3"
},
"grading": {
"#odata.type": "#microsoft.education.assignments.api.educationAssignmentPointsGradeType",
"maxPoints": 100
},
"assignTo": {
"#odata.type": "#microsoft.education.assignments.api.educationAssignmentClassRecipient"
},
"status":"draft",
"allowStudentsToAddResourcesToSubmission": true
}
I'm trying to use Google Cloud speech (v1beta1) to analyse phone calls. I can't find the "model" parameter in the C# client library, so I'm constructing my own json message and sending it. This works:
{
"audio": {
"content": "UklGRiavCAA+P8QAAgA....."
},
"config": {
"languageCode": "nl-NL"
}
}
But when I add the phone_call model like this:
{
"audio": {
"content": "UklGRiavCAA+P8QAAgA....."
},
"config": {
"languageCode": "nl-NL",
"model": "phone_call"
}
}
I get an error:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"model\" at 'config': Cannot find field.",
"errors": [
{
"message": "Invalid JSON payload received. Unknown name \"model\" at 'config': Cannot find field.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
Why? Accoding to the documentation I believe my request is valid?
Edit: to answer my own question: turns out I was using a wrong url. The correct url is: https://speech.googleapis.com/v1p1beta1/speech:recognize.
I'm sorry to be the bearer of bad news, but it looks like the phone call model is only supported for en-US, and your language is nl-NL:
https://cloud.google.com/speech-to-text/docs/basics
Scroll down to "Selecting Models". "Command and Search" and "Default" are both listed as available for all languages, but "video" and "phone call" are listed as "en-US only".
I'm trying to set a custom_fields of type enum_value in a task that I'm creating with a POST HTTP request.
I managed to set a custom_field of type number but I'm having issue with the custom_fields of type enum_value
Questions:
Here's what I did so far:
1- I created the custom_fields that I want to populate on asana, I can set custom_fields of type number but not the ones of type enum_value( see picture attached)
Here's my code (I tried different implementations to set the custom_fields that were incorrect) :
var task = {
data: {
assignee: "me",
workspace: "1234567",
projects: "9876543",
parent: null,
custom_fields: {
"1234567898": 333, // this works
"98765": "Public" // this custom field holds an enum_values, this implementation doesn't work
},
notes: "Test notes"
}
}
It looks like you put the name of the enum_value instead of the id. Here is an example of a PUT/POST request and response:
# Request
curl --request PUT -H "Authorization: Bearer <personal_access_token>" \
https://app.asana.com/api/1.0/tasks/1001 \
-d
'{
"data": {
"custom_fields":{
"124578":"439"
}
}
}'
# Response
{
"data": {
"id": 1001,
"name": "Hello, world!",
"completed": false,
"...": "...",
"custom_fields": [
{
"id": 124578,
"name": "Priority",
"type": "enum",
"enum_value": {
"id": 439,
"name": "High",
"enabled": true,
"color": "red"
}
},
"~..."
]
}
}
It's admittedly a bit buried, but if you look in the Custom Fields section of the getting started documentation, there is an example of creating custom fields under "Accessing Custom Field values on Tasks".
Running into parseError attempting to follow the "start a resumable session" YouTube Data API - Resumable Uploads documentation.
complete list of efforts ,response and code
I read on the Google APIs - "Global domain errors" page "parseError The API server cannot parse the request body."
I have watched "YouTube Developers Live: Debugging & Dealing with Errors" still know clue there
I have read "stack over flow" for similar questions, but never get answered,or answers are still un clear
the test youtube account i want to upload to has a youtube channel with videos
I tried the client PHP upload API, but found out later its not a resumable upload.
I thought resumable upoad would be a better option, so i dont frustrate users, by wasting there time,if there connection drops out....
I am runing PHP from hostgator account
I noticed how when i did not get an error, it would return the regular snippet and status data and not the "Step 2 - Save the resumable session URI" data
I am using long lived access tokens pulled from my database...in the requests, the youtube user has a channel with videos before i stored the access tokens
I do check the access tokens with tokeninfo?
I noticed changing "uploadType" to "uploadtype" would produce "message": "Media type 'application/json; charset=utf-8'
is not supported. Valid media types: [video/*, application/octet-stream]",following this error by changing content type to "application/octet-stream" would return "kind = youtube#video
object with json snippet,status" not the Step 2 - Save the resumable session URI, so i changed things back to "uploadType" and "application/json; charset=utf-8" now facing same parse error
I notice in the docs "Parameter values in the request URL must be URL-encoded." when i would urlencode() "Parameter values" it would return errors or parseError when i removed the urlencode function
Even changing "Host: www.googleapis.com" to "Host: https://www.googleapis.com" would produce "The requested URL /upload/youtube/v3/videos was not found on this server. That’s all we know."
parse error appears to be most persistent so far
I have changed urlencode() to rawurlencode() still parse error
i would add charset=utf-8;multipart/form-data;application/octet-stream to content type header, still parse error
I notice content type on string is text/plain; charset=us-ascii not sure if google server expects pure application/json
any help would be great…
Array
(
[response] => Array
(
[0] => {
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
)
[headers] => [
"POST \/upload\/youtube\/v3\/videos?uploadType=resumable&part=snippet,status HTTP\/1.1",
"Host: www.googleapis.com",
"Authorization: Bearer ya29.vAAY5n3SJq3uCG7z4tOhehDxYj9Z7mxFENtD5PKF_dJqFlLqwCktRHTrEJkUgY_NrJD3KMetKeBA_w",
"Content-Length: 303",
"Content-Type: application\/json; charset=utf-8",
"X-Upload-Content-Length: 20121",
"X-Upload-Content-Type: video\/*"
]
[curl_resource] => Resource id #18
[video_aray] => {
"snippet": {
"title": "test video",
"description": "testing api",
"tags": [
"any",
"thing"
],
"categoryId": 25
},
"status": {
"privacyStatus": "public",
"embeddable": true,
"license": "youtube"
}
}
[json_requestbody] => {
"snippet": {
"title": "test video",
"description": "testing api",
"tags": [
"any",
"thing"
],
"categoryId": 25
},
"status": {
"privacyStatus": "public",
"embeddable": true,
"license": "youtube"
}
}
[request_url] => https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status
[content_type_of_request] => text/plain; charset=us-ascii
[0] => text/plain; charset=us-ascii
[1] => text/plain; charset=us-ascii
)
Source
public function startResumableSession()
{
$videoResource = array( 'snippet'=>array('title'=>"test video",'description'=>"testing api",
'tags'=>array("any","thing"),'categoryId'=>25),
'status'=>array('privacyStatus'=>"public",'embeddable'=>True,'license'=>"youtube"));
$requestBody = json_encode($videoResource,JSON_PRETTY_PRINT);
$headers = array
(
"POST /upload/youtube/v3/videos?uploadType=resumable&part=snippet,status HTTP/1.1",
"Host: www.googleapis.com",
"Authorization: Bearer ya29.vAAY5n3SJq3uCG7z4tOhehDxYj9Z7mxFENtD5PKF_dJqFlLqwCktRHTrEJkUgY_NrJD3KMetKeBA_w",
"Content-Length: ".strlen($requestBody),
"Content-Type: application/json; charset=utf-8",
"X-Upload-Content-Length: 20121",
"X-Upload-Content-Type: video/*"
);
/* Parameter values in the request URL must be URL-encoded. */
$url = "https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_POSTFIELDS,urlencode($requestBody));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE);
$result = curl_exec($ch);
$json = json_decode($result);
/* Check request body contenttype */
$finfo = new finfo(FILEINFO_MIME);
$t1= $finfo->buffer($requestBody);
$t2 = $finfo->buffer("test");
$t3 = $finfo->buffer(utf8_encode("test"));
/* debug info */
return array( 'response'=>(array)$result,
'headers'=>json_encode($headers,JSON_PRETTY_PRINT),
'curl_resource'=>$ch,
'video_aray'=>json_encode($videoResource,JSON_PRETTY_PRINT),
'json_requestbody'=>$requestBody,
'request_url'=>$url,
'content_type_of_request'=>$t1,$t2,$t3
);
}
Easy answer is - you do it wrong.
You are NOT supposed to add "POST", "Host:" and "Content-Length:" into $headers because that is generated by curl (CURLOPT_URL and CURLOPT_POSTFIELDS).
YouTube API works correctly. It is not their fault.
I have to update the featured video of my channel using youtube api.
When I sent PUT request using api explorer of the form
PUT https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&key={YOUR_API_KEY}
{
"brandingSettings": {
"channel": {
"featuredChannelsTitle": "featured channel",
"featuredChannelsUrls": [
"http://www.youtube.com/user/channelname"
]
}
},
"id": "channelId"
}
I am getting response as follows
404 Not Found
- Show headers -
{
"error": {
"errors": [
{
"domain": "youtube.channel",
"reason": "channelNotFound",
"message": "Channel branding options not found.",
"locationType": "parameter",
"location": "id"
}
],
"code": 404,
"message": "Channel branding options not found."
}
}
Please let me know where I am going wrong.
I was giving the wrong channel ID. But now I am trying with the correct Channel Id, and I am getting yet another error message.
Content-Type: application/json
Authorization: Bearer ya29.1.AADtN_X2UP_3BfFvUwAkvLp0d0mk1U-itJNVtWMPEJQU8G7INQ5q-UpI1yNMYniiLQ
X-JavaScript-User-Agent: Google APIs Explorer
{
"id": channelId,
"brandingSettings": {
"channel": {
"featuredChannelsUrls": [
" http://www.youtube.com/user/USERNAME"
],
"featuredChannelsTitle": "Featured Channels"
}
}
}
Response is 400 Bad Request
- Show headers -
{
"error": {
"errors": [
{
"domain": "youtube.channel",
"reason": "brandingValidationError",
"message": "Channel branding validation failed.",
"locationType": "parameter",
"location": "brandingSettings"
}
],
"code": 400,
"message": "Channel branding validation failed."
}
}
If you can provide me a sample request it would be really helpful
As it says in the error message, it couldn't find the channel, make sure you are giving the right channel id.
The way to do it in API, do a channels->list request and use that response object, modify it and put it back. (Most important make sure the id is there and set.)