Can we get data as Response using Post Method for API Testing using RestAssured Cucumber - api

Here is the full question :
As a Portfolio API, I should be able to retrieve details for a given Account and Account type from Balance API, so that i can pass over the same to the UI for the end users to view the same.
Scenario 1 - Verify the response when Portfolio API invokes the
POST /v1/accDetails endpoint for a given account details (Checking)
Given client has a valid auth token for the api
And Portfolio API has the following
Account Number 1234567890 (10 characters).
Account Type 'CHQ' (3 characters)
When Portfolio API sends a POST request to Balance API
Then Portfolio API will receive the response code as <00>
And response body will have the following (not limited to below fields)
Account Type, Account Number, Account ID, Account Name, Account Balance, Product TypABA Number, Interest Rate, Interest Earned to DateStatus.
Now my question is we can do this using GET Method but can we do this using POST method or not? When we use post that mean we are going to add something but I do not want to add any account. I just want to get account details.

Since you have only a few parameters to send via GET, the best approach is to use [GET].
We can use the [POST] if we really need it to do so.
But if you can use [GET] for that, then the best approach is to use [GET].
Also can refer: REST API using POST instead of GET.

Related

YouTube Reporting API: Create/Download reports using channel oauth token

We have a channel oauth token from a channel owner and we are able to use the YouTube Analytics API to get details, including revenue, on the channel/videos.
I would like to use the YouTube Reporting API to create a report that we need daily and not use the more resource limited Analytics API but I am not able to see the larger list (43) of report types that include system managed reports with revenue, such as content_owner_ad_revenue_raw_a1 and content_owner_estimated_revenue_a1 with any value for the onBehalfOfContentOwner argument in a service.reportTypes().list API call.
I can see a list of 43 available reports when using a CMS oauth token, passing the partner_id value as the onBehalfOfContentOwner.
I can not find a working value when using a channel oauth token, any value I tried (oid for the video for example) results in an error response.
When I use None as the value for onBehalfOfContentOwner I see a different list (for both cms and channel oauth) of 18 reports that do not include any revenue data.
What value should I use with a channel oauth to get the revenue information from Reporting API, similar data that I am able to get from Analytics API using the same token?
Snippet from the list of 43 report types that I see when using cms partner_id on a CMS level is attached.
The list of 18 report types that I get when I pass None to onBehalfOfContentOwner is also attached (the same list for cms and channel oauth).
I tried the following:
service.reportTypes().list(
onBehalfOfContentOwner=oid,
includeSystemManaged=True
).execute()
returns error, any other value I could think of instead of oid returns error
with
service.reportTypes().list(
onBehalfOfContentOwner=None,
includeSystemManaged=True
).execute()
I get a list of 18 report types that doesn't include revenue information, also there is no systemManaged column.

Using Instagram's Graph API, how can I retrieve post data (media url, caption, poster username, etc)

I want to use Instagram's Graph API on my backend server to retrieve data about an Instagram post. On my frontend, users will submit a post URL (like https://www.instagram.com/p/CAvPIm2lszQ/). Then on my backend, I want to take the ID of the post from that URL (so in this case CAvPIm2lszQ) and then I'm hoping that I can pass that ID thru the Instagram Graph API and then retrieve the data that I need (media URL, caption, poster username, etc.).
So would that be possible? I did find documentation on "IG Media" for the Graph API, but under permissions, it says, "A Facebook User access token from a User who created the IG Media object, with the following permissions.."
Unless I'm misunderstanding it, I'm not sure if I'll be able to access posts from various public accounts. I think it's also worth mentioning that my users are not logging into their Instagram accounts to use my service so the only possible "User access token" would be my own.
Any ideas on how I can go about this? I was using the instagram.com/p/{post_id}/?__a=1 endpoint to meet my needs before but it doesn't work on my production server for some reason. So I'm kinda stuck.
Most probably you will not be able to achieve that using Instagram API. First of all the ID you are referring to CAvPIm2lszQ is not the ID that you will use for getting IG Media. The ID is different (it's numeric value like in the sample request from the page you've linked). The full URL that includes CAvPIm2lszQ is in the shortcode field.
At the moment it is not possible to look for the post detail using shortcode. If you want to use that endpoint you need to get the real post ID first, for instance by listing list of posts from given user.
But in order to do so - you need to use Facebook login authorization window to get token from given user. Alternatively you can try to request https://developers.facebook.com/docs/instagram-api/guides/business-discovery but it requires going through App review and having your own company to pass the Business Verification. Keep in mind that this endpoint returns information only about Instagram Professional accounts (Business/Creator account). You will not be able to get information about regular accounts.
And the last thing about ?__a=1 endpoint. This is not the official Instagram API. They use it only for their own purposes. Most probably your server IP address has been blocked due to sending too many requests.

Porting from NVP to REST API

I am currently using PayPal's NVP API. And using the below methods.
TransactionSearch (To pull in historic and recent transactions)
GetTransactionDetails (To fetch detail for each transaction)
TransactionSearch using PROFILEID (To get subscription/recurring transactions related to a particular subscription/recurring profile using the Subscription/Profile ID)
RefundTransaction (To refund a transaction)
ManageSubscriptions (To manage - cancel, suspend, reactivate a particular subscription using the Recurring/Subscription/Profile ID)
GetBalance (To get balance for a particular account)
MassPay (To send money to other PayPal accounts using the email address) I would like to know and get assured that I won't be missing anything when I port to REST, and will get all the details (including all the fields) that I have been getting from the NVP response.
Question 1
Can you map me to the respective REST methods for the above 7 cases that I have listed?
Question 2
Can I use the same credentials for REST API? Or do I need to use something else? Doing so will require the users to reconnect to my system via some other method?
Question 3
Another thing I wanted to know is, that if the REST API can be used to pull in historic data(data for all date ranges)? Is there any restriction on the user-type or type of PayPal account or date-ranges or anything else when using the REST API?
Question 4
What else do I need to take care of when I port from NVP to REST?
Please help!

Detect an invalid paypal email using MassPay Paypal API

I'm using MassPay Paypal API to make payments.
I was able to test it and is working pretty well using sandbox accounts.
The problem is I couldn't find a way to identify if the email that is going to receive money is a valid paypal email.
I tested it using a fake email and money was taken from the payer sandbox account even though the email (the one that should receive the money) doesn't have a paypal account associated, and the API response was as if it was a successful request.
I found this method to get the verification status of an account, but there is no much info in the documentation or any other info that helps me understand if this is what I'm looking for or how to apply it.
You will need an API operation called GetVerifiedStatus API Operation under PayPal adaptive accounts. Refer the below:
https://developer.paypal.com/docs/classic/api/adaptive-accounts/GetVerifiedStatus_API_Operation/
https://developer.paypal.com/docs/classic/adaptive-accounts/gs_AdaptiveAccounts/
Sample API request:
API end point: https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus
requestEnvelope.errorLanguage = en_US&emailAddress = email#test.com&firstName = Firstname&lastName = Lastname&matchCriteria = NAME

Paypal Payments (Authorization & Capture) not returning Authorization ID

According to the documentation the paypal payment method should be able to do Authorization & Capture just fine. The following excerpt under the PayPal authorizations excerpt specifically states how to go about it:
First get payment approval and execute the payment as you normally would do for a PayPal payment. Once you successfully execute on the payment authorization, PayPal responds with a new set of HATEOAS links, including a capture link that you use to capture the payment.
So if im following correctly the flow for doing Authorize & Capture is as follows:
Create a Payment
Redirect User to HATEOAS link approval_url to get them to sign into paypal.
Be returned to success (or cancel, but not in this example) link.
Get the Payment to see what's changed, get the shipping address / etc....
Let the customer review the details
Execute The Payment to commit to the hold on funds.
At this point an AuthorizationID / HATEOAS Link should hold information about the authorization.
Some time later use the authorization ID to Capture, and voila, we're done.
Now this is all fine and dandy, but in my tests on the sandbox environment I'm having trouble retrieving the authorization ID anywhere.
Here's my HATEOAS Links I receive from my Execute Step:
As you can see, only the self reference is returned, according to the documentation there should be one capture link at the least that should have the authorizationID in it.
Also, nowhere in the response body is any authorization ID. However, If I look at the payment in my sandbox paypal dashboard:
And once I drill down into it:
Sure enough if I call the Authorization.Capture API call against 8B633793L37511009 it captures as you would expect. However I can't find a programmatic way to determine this number.
How am I supposed to store the authorization number so my tooling can capture later when our business conditions have been met?
In the beggining, when you create the payment with intent authorize you should be getting an authorization object within the response. This object has the id you need for the capture later.
Check this blog post to see if you're missing something fundamental in the picture.
I followed the tutorial and executed the sample requests via curl. As you can see, I got the authorization id under transactions->related resources->authorization->id
Then I used the id in the URL and successfully captured the payment.
Hope this helps, if it doesn't, please elaborate and maybe I will be able to help you further. Good luck!