Amadeus Hotel Booking returns null through Amadeus API Response returns properly - amadeus

ObjectMapper mapper=new ObjectMapper();
HotelBooking[] hotelBook=null;
try {
String jsonInString=mapper.writeValueAsString(hotelBookRequestDTO);
hotelBook=amadeus.booking.hotelBookings.post(jsonInString);
}
The above hotel booking returns null when calling the API with the Java SDK 4.0. I debugged the Amadeus SDK, it returns the Response Object properly but the returned method doesn't properly convert the Response object to HotelBooking[].
public HotelBooking[] post(String body)throws ResponseException{
Response response = client.post("/v1/booking/hotel-bookings", body);
return (HotelBooking[]) Resource.fromArray(response, HotelBooking[].class);
}
Can some one from the Amadeus development team can help on this issue?

We deployed the new version 4.0.1 of Amadeus Java SDK which fixes the issue. Indeed there was a bug related to the resource HotelBooking.java, where the AssociatedRecord returned by the Hotel Booking API should be an object array instead of object.

Related

Using RestSharp I ever see "{\"message\": \"TypeError: sign() takes at least 2 arguments (0 given)\", \"exception\": \"TypeError\"}"

I using RestSharp (v 107.3.0.0) to post data on a Web API, when I using postman to test te post is ok, bu when I using RestSharp ever I receive:
"{"message": "TypeError: sign() takes at least 2 arguments (0 given)", "exception": "TypeError"}"
Resumin my code:
var client = new RestClient(http://192.168.2.59);
var request = new RestRequest("api/sign", Method.Post);
/*
here I set some AddParameter, but using parameter or not I ever seen the same error. For that reason I will not put these parementer and too proteted some sensitive proyect information.
*/
RestResponse response = await client.PostAsync(request);
The error will to be clear, but sing is not a method, is a resource.

How to get the current TraceId and SpanId

This article, https://devblogs.microsoft.com/aspnet/improvements-in-net-core-3-0-for-troubleshooting-and-monitoring-distributed-apps/, tells me that the field TraceId is available as a correlation id, which is great!
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
=> ConnectionId:0HLR1BR0PL1CH
=> RequestPath:/weatherforecastproxy
RequestId:0HLR1BR0PL1CH:00000001,
SpanId:|363a800a-4cf070ad93fe3bd8.,
TraceId:363a800a-4cf070ad93fe3bd8,
ParentId: Executed endpoint 'FrontEndApp.Controllers.WeatherForecastProxyController.Get
(FrontEndApp)'
In fact, I can see that in our log sink this works as advertised: When web application A serves a request and in doing so invokes web application B, both of them write the same TraceId value to the log.
As far as I understand, any ASP.NET Core application that receives an incoming Request-Id header will attach the same header to outgoing requests, but if the header does not exist on the incoming request, an new value will be generated for the outgoing request.
We have been asked to add that value to the response from web application A, but it is (not surprisingly) not available on the incoming request.
I have been looking at the System.Diagnostics.Activity class, but accessing Activity.Current isn't giving me an instance with anything useful - the TraceID is just {} - i.e. empty.
My question is this: How can I access the TraceId value in the context of a web application?
-S
I had the same problem when I tried to add a header with TraceId value.
Doing some tests with ModelValidation, I saw then in this kind of error response the "traceId" value was correct, but I couldn't obtain this value from http context variable in any way.
Then I went to net core source code to see DefaultProblemDetailsFactory implementation and surprise! The "traceId" value is obtained doing this:
var traceId = Activity.Current?.Id ?? httpContext?.TraceIdentifier;
Yes, you can get THE traceId using Activity static variable.
You can get tracid and spanid in dictionary.
using var subject = _tracer.BuildSpan($"Operation").StartActive();
var spanContext = subject.Span.Context;
var dictionary = new Dictionary<string, string>();
_tracer.Inject(spanContext, BuiltinFormats.TextMap, new TextMapInjectAdapter(dictionary));

How to Emulate a POST Request from PostMan - For a series of Integration Tests in a WebAPI Development

I am using PostMan as part of the testing regime for a WebAPI service development that I am working on. In order for external parties to gain access to our WebAPI service they first need to obtain an access token.
The POST request returns some JSON containing the required access token:
{
"access_token": "anencryptedaccesstoken",
"scope": "am_application_scope default",
"token_type": "Bearer",
"expires_in": 3218
}
I am putting together a series of integration tests which need to emulate the POST calls from POSTMAN. I am currently using System.Net.WebClient to achieve this. I am not sure what I need to do in order to achieve my goal. Here is a function that I am using to try and obtain the access token:
Public Shared Function GetAccessToken(ByVal endpoint As String, wc As WebClient) As String
Dim result As String = ""
Dim data As Byte() = Nothing
'Header information
wc.Headers.Add("Authorization", "Basic <alongencryptedstring>")
wc.Headers.Add("Content_Type", "application/x-www-form-urlencoded")
result = wc.UploadString(endpoint, "POST", "")
Return result
End Function
The 'Body' tab in PostMan contains the following entries:
grant_type - client_credentials
Content_Type - application%2Fx-www-form-urlencoded
In this instance as far as I am aware there is no 'data' element to the PostMan request hence the empty string in my use of UploadString. The function returns the following error:
"The remote server returned an error: (415) Unsupported Media Type."
I am new to web app development so please bear with me, I am finding it difficult to phrase what I think are meaningful question in the context of this post, I hope however that I have ssupplied sufficient information to convey the gist of my problem and for someone to be able to respond appropriately.
Kind Regards
Paul.

How to consume REST API (Liverail) via webservice using Java

I am a complete newbie to webservices but have some experience in Java. We have been provided with Liverail API documentation with a list of Entities that we can consume. This is what their doc says:
"Logical flow An API client must always use the /login method followed by the /set/entity method. All the remaining APIcalls will be executed on the selected entity. If you need to switch the current entity, you should use /unset/entity followed by a new /set/entity with the new entity ID as parameter. It is also recommended to call /logout once the API client ends its execution"
XML response format
The LiveRail API XML response is always formated like bellow.
My dilema is that i dont know how to make the GET calls.
What i would like to do in java is :
Create a http login to API webservices
Fetch a list of data (response is in XML format)
3 Convert this XML response into CSV file.
Any help will be highly appreciated.
Why not using RestTemplate?
final String uri = "http://localhost:8080/springrestexample/employees/{id}";
Map<String, String> params = new HashMap<String, String>();
params.put("id", "1");
RestTemplate restTemplate = new RestTemplate();
EmployeeVO result = restTemplate.getForObject(uri, EmployeeVO.class, params);
System.out.println(result);
Here is for more tutorials http://howtodoinjava.com/2015/02/20/spring-restful-client-resttemplate-example/

400 Bad Request error when using .net Paymill Wrapper

I'm trying to use the .net Paymill Wrapper
When trying to add a subscription, I'm getting back a 400 Bad Request.
To illustrate the problem, I created a branch and changed the Sandbox console app to call the method to test addSubscription
The problem is happening here where the request is actually posted.
The content posted is: (as an example)
client=client_bbe895116de80b6141fd&
offer=offer_32008ddd39954e71ed48&
payment=pay_81ec02206e9b9c587513
It appears this hasn't been updated for sometime, and the original author is unresponsive via email or twitter, so I've forked the repo and am trying to fix the error.
I had a look at your code and found out that you are not creating the offer object correctly.
In your addSubscription method (SandboxConsole project), i found this code snippet
Subscription subscription = new Subscription();
subscription.Client = new Client() { Id = "client_bbe895116de80b6141fd" };
subscription.Offer = new Offer() { Id = "offer_32008ddd39954e71ed48" };
subscription.Payment = new Payment() { Id = "pay_81ec02206e9b9c587513" };
Offer object should be initialized with parameters like amount, currency, interval.
Since the offer object doesn't exist, assigning a subscription to it fails, giving you bad request error.