Can I intercept the RavenDB HTTP API Post with custom code - asp.net-web-api

When I would do a REST call form my javascript client to the server via domain.com\api\docs\bobs_address
Is it possible to intercept the http post at the server endpoint that means inside my web api controller or does the call of the above url go directly into my Raven database?
Assuming there is a document with an id of "bobs_address", RavenDB will respond with the contents of that document and an HTTP 200 OK response code:
HTTP/1.1 200 OK
{
"FirstName": "Bob",
"LastName": "Smith",
"Address": "5 Elm St."
}
If the URL specified does not point to a valid document, RavenDB follows HTTP conventions and responds with:
HTTP/1.1 404 Not Found

In RavenDB 3.0, we are using OWIN as our middleware, and you can intercept the requests before/after they arrive to RavenDB.
However, what do you want to do with them once you intercepted them?

Related

Graphql with Jmeter

I am trying to use jmeter to Automate graphql API testing. I have done the manual testing with postman. However, since some one suggested i am trying to automate with jmeter. unfortunately i am new to API testing itself and having great difficulties.
As i understand Graphql method only deals with POST, but in my Jmeter it is throwing an error, but when i change it to GET, i get 200 ok response.
Also in the body data i am directly entered the graphQL query is this correct.
In the return response data i don get any information related to my query.
I have added header manager with
Content-type = "Application/json"
Accept-encoding
Authorization
Accept
Connection
My graphql query is
query{cmCases(filters: {caseId:"case-6"})
{
items {
id
}
}
}
In the response i am just receiving meta data.
Looking into HTTP Methods, Headers, and Body chapter of the GraphQL documentation GraphQL supports both GET and POST methods so you can choose whatever you want or whatever you need
Looking into HTTP Headers documentation chapter header values are case-sensitive so you need to change Application/json to application/json in the HTTP Header Manager
Given you can successfully execute request in Postman you should be able to record this request by JMeter's HTTP(S) Test Script Recorder, just configure Postman to use JMeter as the proxy
Starting with upcoming JMeter 5.3.1 or 5.4 you’ll be able to use the GraphQL Http Request.
Until it is released you can try a nightly build:
https://ci.apache.org/projects/jmeter/nightlies/
See:
https://github.com/apache/jmeter/pull/627

Google Calendar Event Insert HTTP message format?

Google provides the HTTP message format for all the Oauth messages but nothing when it comes to the Calendar's API.
I suspect they want you to use one of their libraries -- but I don't use any of the languages associated with their libraries.
I'm using C++ and forming my own HTTP headers and message content.
Can anyone provide a standard HTTP format for Calendar-event-insert?
I know it must be in JSON construction.
The data I want to send is:
Calendar ID will be "primary"
Summary
Description
Start time
End Time
Based on oauth messages - I'm assuming the message may also have to contain:
ClientID
AccessToken
Scope
redirect_uri
I am looking for correct "Key" strings(case sensitive) and format.
Thanks in advance for any help.
You can do this all your self. The doucmentation is all there
Calendar event.insert
If all you want to do is see the HTTP request that is made by the api you can use If you use the event.Insert try me You can see the request it builds and test that its working
POST https://www.googleapis.com/calendar/v3/calendars/primary/events HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"end": {
"date": "2020-01-01"
},
"start": {
"date": "2020-01-01"
},
"description": "test",
"summary": "test"
}
With a post body of events.resource
oauth
If you have your own C++ oauth library you can probably use that to get an access token. Once you have the access token you simply need to add a Authorization header to the post request above with a bearer token of the access token.
Sorry i cant help much with the code for c++ but i made my own library for .net 3.5 because it was not supported by googles .net client library, so i can tell you that its doable you just have to do it all yourself.
Google c++ library
There is a c++ library its just deprecated but that doesn't mean you cant dig around in their code for a bit of help in doing this Google apis cpp client

How can I make a POST request to my Dynamics CRM from Postman?

I am having trouble making a successful HTTPS Post Request to my Dynamics Health 365 CRM.
My goal is to update the "description" field for one specific contact through a Post request.
I am able to make a successful Get request for this specific contact by passing in their contactid to the /contacts path.
get req
However, I am unable to make a Post request on this URI for my CRM site. I am consistently met with a "405 - Method Not Allowed" response.
post req body
Here are the headers I have set. Is there something I am not doing correctly to add content to a certain field for a certain contact?
post req headers
I have also tried to use a Put request but am met with the same 405 error.
I do not know of any guidance on the Dynamics CRM Web API documentation. If there is any content specifically on making Post requests to the Dynamics CRM, I would be more than happy to look to that. I am just looking for any guidance on this because I feel like I have totally hit a wall on this for the last few days. Anything helps, thank you!!
This is for a dynamics CRM portal
I am able to make Get requests on this same URL
I think I need to set the key-value pair of the data I want to update in the body of the request, but that seems not to be correct. Either that, or I am not doing some preliminary step in order to allow for that Post body content to be applied to the contact I am passing.
I want the "description" field in the contact's data to update to the value I set it to. See second image of my post request body.
I recommend you to check the documentation, it has a Postman specific section and some helpful examples.
About your question, updates use the HTTP PATCH verb (POST is used for create operations):
PATCH [Organization URI]/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000001) HTTP/1.1
Content-Type: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"name": "Updated Sample Account ",
"description": "This is the updated description of the sample account"
}
If you're trying to update a single attribute, you can use PUT as you did but the URL must include the attribute name (/name after the record id in this case):
PUT [Organization URI]/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000001)/name HTTP/1.1
Content-Type: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
{"value": "Updated Sample Account Name"}
More about update operations on the documentation.
You can also check out the Postman collection template I created some time ago in GitHub.

Spring security OAuth2 request as object instead of query parameters

I want to customise OAuth Endpoint URI's.
I want to sent parameters in post body instead of query params.
now my request is like -
example.com/oauth/token?grant_type=password&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}&username={USERNAME}&password={PASSWORD}
But I want it like this.
example.com/oauth/token
Request body -
{
grant_type=password,
client_id={CLIENT_ID},
client_secret={CLIENT_SECRET},
username={USERNAME},
password={PASSWORD}
}
How should I do it?
The token endpoint of a properly-implemented authorization server does NOT accept GET requests because RFC 6749, "3.2. Token Endpoint" says as follows:
The client MUST use the HTTP "POST" method when making access token requests.
So, your authorization server's token endpoint should reject GET requests.
RFC 6749, "4.3. Resource Owner Password Credentials Grant" says that request parameters of a token request using Resource Owner Password Credentials flow should be embedded in the request body in the format of "application/x-www-form-urlencoded". The following is an excerpt from "4.3.2. Access Token Request".
POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded
grant_type=password&username=johndoe&password=A3ddj3w
Therefore, you don't have to customize your authorization server. If the server is implemented correctly, its token endpoint accepts POST requests.
The token endpoint created by spring-oauth2 already deals with POST as well.
It would be hard to customize it to accept a JSON request body, because the TokenEndpoint class expects all the params as #RequestParam params.
However, if your concern is about security (as HTTPs does not secure query parameters) you indeed can send the request parameters through post. It is just a matter of sending the request in the form "form-data" or "x-www-form-urlencoded". These are 2 ways of sending arbitrary key-value parameters in the request body, in a way that appears to the server as they are regular request parameters. So it is a matter of making your client using this.
Also, note that in spring-oauth2 it is possible to disable the GET endpoint, this way forcing your clients to use POST with one of the ways above.

Invoking JAX-WS web services from remote machine using JQuery and AJAX

I am new to Java SOAP web services. Recently I have created a web service using the JAX-WS specification. This is deployed in the WebLogic server I am using in my machine. Now when I want to invoke the web service from the web application written in JavaScript remote machine on another server, it giving me the following error.
I have also browsed for some other similar kind of posts like this
I am sending the request using JavaScript and SoapClient.js Library.
My invocation code is:
SOAPClient.invoke("http://inhydkvaranasi1:7001/TodoWS/TodoListService",
"getTodos", p1, true, function(data) {
$("#todolist").html('');
if (Object.keys(data).length < 1) {
$("#todolist").html(
"<h4>No Todos Available right now!</h4>");
} else {
Object.keys(data).forEach(
function(key) {
$("#todolist").append(
"<li>" + data[key]["task1"]
+ "(Priority "
+ data[key]["id0"]
+ ") </p>");
});
}
});
The request sent by the XMLHttpRequest() object did not get a response header as Access-Control-Allow-Origin in the XML response.
How could I solve this problem? So that my web service can be used publicly by any user from different domain on different server.
Look at the CORS HTTP headers (from codingpedia.org):
Client side HTTP request headers. These are headers that clients may use when issuing HTTP requests in order to make use of the cross-sharing feature:
Origin: URI indicating the server from which the request initiated. It does not include any path information, but only the
server name
Access-Control-Request-Headers: used when issuing a preflight request to let the server know what HTTP headers will be used when the
actual request is made
Access-Control-Request-Method: used when issuing a preflight request to let the server know what HTTP method will be used when the
actual request is made
Server side HTTP response headers. These are the HTTP headers that the server sends back for access control requests:
Access-Control-Allow-Origin: specifies the authorized domains to make cross-domain request (you should include the domains of your
clients or “*” if you want the resource public and available to
everyone – the latter is not an option if credentials are allowed
during CORS requests)
Access-Control-Expose-Headers: lets a server white list headers that browsers are allowed to access
Access-Control-Max-Age: indicates how long the results of a preflight request can be cached.
Access-Control-Allow-Credentials: indicates if the server allows credentials during CORS requests
Access-Control-Allow-Methods:
indicates the methods allowed when accessing the resource
Access-Control-Allow-Headers: used in response to a preflight request to indicate which HTTP headers can be used when making the
actual request

Resources