Unable to use the REST API services in Oracle Business Intelligence Publisher 12.2.1.2.0 server - json

I have an Oracle Business Intelligence Publisher 12.2.1.2.0 server running and I am trying to call the REST API services in order to access a report (i.e, TestReport) present over the server by using Postman tool. I am using various methods (GET, POST, PUT and DELETE) available over the Oracle documentation to get the relevant data from the server. But, only three of the methods (Get report definition, Get report sample data and Get XDO schema) are working fine and the rest are giving either of the following errors: 400 Bad Request or 415 Unsupported Media Type or 404 Not Found or 405 Method Not Allowed or Could not get any response. Most of the errors are associated with the POST and PUT methods so there may be some data format issue with the request. The request URL is: http://localhost:port/xmlpserver/services/rest/v1/reports/Components%2FTestReport/
Please help.
I have attached one of the responses for "Run Report".
Post Method:: Header
Post Method:: Body

SOLVED::
Add the associated headers and body in the proper format and then send the POST request.
For Example- For running a report
In Postman tool:
URL: http://localhost:port/xmlpserver/services/rest/v1/reports/Components%2FTestReport/run
Authorization:: username/password --> Preview Request
Headers:: (Key/Value)
1. Authorization/Basic...
2. Content-Type/multipart/form-data; boundary="Boundary_1_1153447573_1465550731355"
3. Accept/multipart/form-data
Body::
--Boundary_1_1153447573_1465550731355
Content-Type: application/json
Content-Disposition: form-data; name="ReportRequest"
{"byPassCache":true,"flattenXML":false,"attributeFormat":"pdf"}
--Boundary_1_1153447573_1465550731355--
It will generate the report in PDF format
Refer: https://docs.oracle.com/middleware/12211/bip/BIPAP/op-v1-reports-%7BreportPath%7D-run-post.html

Related

API POST response returning 400 response code in Jmeter

I am trying to create a test plan using jmeter.its for an API Post request, I have a header manager, bodydata, checked for spellings and the syntax seems to be correct. However, Im getting 400 response code with the following error shown in the attached image. Anyone with an idea how I can resolve this? Thank you. the error
Here is the request the request
The user doesn't have to be logged in, i have added a header manager, I have also noticed there header has a cookie value thats hard coded but it appears to be the same in every request. In the UI the API request returns 200 and thats what im expecting with the Jmeter script.
In its current form the question cannot be answered comprehensively.
HTTP Status Code 400 means that
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).
Check that your ${site} and ${csVersion} variables have their respective values using Debug Sampler and View Results Tree listener combination
Cross check headers sent by JMeter and by the "UI", the most important is Content-Type
Use a sniffer tool like Wireshark of Fiddler and capture the requests which are being sent by JMeter and the "UI", the requests must be exactly the same apart from dynamic parameters which need to be correlated
The issues was being caused by an anti-forgery cookie which was hard coded in the request.I used a regex to extract the value from a previous request and used a variable value from the regex to make sure the same value is being passed on to the request that was failing.

Rest call failed with client error, status code 406 NotAcceptable

When I test with Advanced Rest Client(Arc) all nine API calls to REST API works fine.
I use method Get with two headers the first is Authorization Bearer
the second one is Content-type application/json. It works even if I remove
header Content-type application/json
Here is a screenshot of the response from Arc. This same REST API call give error from Azure Data Factory(ADF).
Sceenshot from Arc
I call nine REST API from Azure Data Factory(ADF) with the same base url but different Relative URL.
Out of these nine 6 works perfect.
When I use Azure Data Factory(ADF) I use additional header
Authorization Bearer #{activity('GetToken').output.access}
What is strange is that the exact same call from Arc works fine but I get error when I call from ADF. Note also that I get the exact same error if I remove the additional header
Authorization Bearer #{activity('GetToken').output.access}
I mean that the code in REST API doesn't know if the call is comming from Arc or ADF.
Note also the the error is from the source side so my call to REST API with method GET
can't be handled by the REST API code for some reason.
According to the documentation for the REST API it says that
Headers Content-type application/json and
Authorization Bearer
I tried to add a second additional header in ADF Headers Content-type application/json
but I get REST connector ignores any "Content-Type" header specified in additional headers when request body is empty.
I have tried to find any sensible information about my error but there no one that have had any similar. What I find very strange is that 6 Rest API calls works fine and the json that we receive when using Arc is valid.
I don't realy understand the error message when saying
Requested format \u0022application/json\u0022 is not supported
Supported MIME types are \u0022application/ld+json\u0022
Here is the complete error message I get Screen shot of error message for ADF
Your response data is JSON LD (Json linked data). Hence you are seeing this error.
To avoid this error use Content-Type header value as application/ld+json.

Dynamic 365 API only returns XML despite Request for JSON

I am using Postman to query a Dynamics 365 Business Central (BC) API. The API is returning XML and I am trying to get it to return JSON. The Microsoft page that gives an example shows the response as being in JSON format.
I tried added my own Request header to denote that I would like JSON returned
Postman says that by adding my own "Accept" Request header it will override the one that is auto-generated
Even so I tried sending the request with the auto-generated "Accept" header disabled and enabled. This is the response ...
Am I requesting JSON the proper way for a REST endpoint? Microsoft's example seems to indicate that JSON can be returned yet I am only able to get XML back as shown below (just a fragment)
There are two different endpoints you are talking about, $metadata which generates the whole CSDL schema in xml format, whereas <endpoint>/companies fetches the data in JSON format.
This can be tested in browser simply pasting these URLs.
https://api.businesscentral.dynamics.com/v2.0/environment name/api/v2.0/$metadata
https://api.businesscentral.dynamics.com/v2.0/environment name/api/v2.0/companies
Note: Pls test it. I don’t have experience with Dynamics BC, but I managed to get these from docs with the idea of my Dynamics CRM experience :)
Correct me if I am wrong. But microsoft dynamics uses both SOAP and Rest call, seems like you need to use Dynamics Odata APIs
You can go through this doc to understand dynamics Odata APIs :- https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/odata

When use AWS Lambda to process mails from mailgun, can't get mails in JSON format

What I am tried to do is to have a lambda function proccess emails forwarded by mailgun.
So far, I have setup mailgun's route so it will forward emails to a AWS api gateway, then the api gateway triggers a lambda function.
The problem comes when I try to process the mail, instead of getting a pretty Json that I am expecting inside the lambda's event.body, I m getting raw post form data like
--cff4e6b3-a3a4-4131-bb8d-90a73f1b4c36\r\nContent-Disposition: form-data; name=\"Content-Type\"\r\n\r\nmultipart/mixed; boundary=\"001a1140216cee404d05440c49e7\"\r\n--cff4e6b3-a3a4-4131-bb8d-90a73f1b4c36\r\nContent-Disposition: form-data; name=\"Date\"\r\n\r\nTue, 20 Dec 2016 13:40:53 +1300\r\n--cff4e6b3-a3a4-4131-bb8d-90a73f1b4c36\r\nContent ......
My question is, what should I do to get the JSON version of the forwarded emails in lambda?
Not sure if you ever came to a solution, but I have this working with the following settings.
Setup your API Gateway method to use "Use Lambda Proxy integration"
In your lambda (I use node.js) use busboy to work through the multi-part submission from mailgun. (use this post for help with busboy Busboy help)
Make sure that any code you are going to execute after all busboy is complete is executed in the 'finish' portion of the busboy code.
This suggests that your mailgun route is misconfigured and ends with a MIME request:
When you specify a URL of your application as a route destination through a forward() action, Mailgun will perform an HTTP POST request into it using one of two following formats:
Fully parsed: Mailgun will parse the message, transcode it into UTF-8 encoding, process attachments, and attempt to separate quoted parts from the actual message. This is the preferred option.
Raw MIME: message is posted as-is. In this case you are responsible for parsing MIME. To receive raw MIME messages, the destination URL must end with mime
From Receiving Messages via HTTP through a forward() action

Creating requests in fiddler2 gives a 401 unauthorized but the 200 negotiated request doesn't follow

I'm trying to use fiddler to generate requests to receive a JSON response. I drag a request that was captured from IE with a 200 response into the request builder then change the Accept header to "Accept: application/json".
After that I execute the request and get a 401 unauthorized response but the negotiation with a following 200 response does not take place. If there another way I can get this to work?
The reason I was heading down this path was to track down why my AJAX requests against the SharePoint 2010 WCF data services were not returning data while using the .getJSON method in jQuery. Turns out the SP2010 WCF data services escape single quotes in the JSON response.
Single quotes should not be escaped according to the JSON spec.