What is the second parameter of method postFile i have set to null. It must be from type EventRepresentation, i don’t have a request body for uploading the file? I don’t understand how to initialize this parameter.
Where is the best way to get the different parts of the url?
The platform URL should be available as environment variable C8Y_BASEURL.
See here: “[…]The Cumulocity IoT exposes the REST endpoint /user/currentUser. The microservice retrieves the Cumulocity IoT address from the C8Y_BASEURL operating system environment variable.”
Be aware that C8Y_BASEURL will not work correctly in a multi-tenant microservice. In that case you can extract the platform url from the response to the /tenant/currentTenant endpoint.
Update: I might be wrong, will test and follow up.
With new SDK and not allowing directly PlatformImpl and PlatformParameter, as i understand the output we don’t need that anymore:
Output:
Use relative URL’s starting with ‘/’ with RestConnector bean to have them resolved automatically against the host defined in PlatformParameters#getHost().
Which sounds good! I don’t need to care about the absolute url anymore.
The reason I looked into this is: I want to change the behavior of the RestConnector for some calls when running in my local development environment (Eclipse). Those calls that target a REST endpoint within my own microservice should execute against http://localhost:80/… so I can debug them accordingly. Anybody ever achieved this?
@Data
public class BinaryInfo {
/**
* Name of the binary object.
*/
private String name;
/**
* Media type of the file.
*/
private String type;
}
@Data
public class EventBinary {
/**
* Name of the attachment. If it is not provided in the request, it will be set as the event ID.
*/
private String name;
/**
* A URL linking to this resource.
*/
private String self;
/**
* Unique identifier of the event.
*/
private String source;
/**
* Media type of the attachment.
*/
private String type;
}