I am working on custom services for updates and inserting new person's images.
The requirement is we are integrated with a mobile app that shows the person's image and if we need to update we can update or insert a new image for the person.
is it possible with a custom service if yes please share the code for it.
Post and update person image with custom services in x++
Your method expects a string with the encoded in Base64. Please check out what JSON object you sent and whether the _image property really contains a Base64-encoded string. I don't know what Postman generates from your parameters. You seem to assume that it does the encoding for you but the error messages suggests otherwise. Or simply provide the right JSON object (raw input).
Post and update person image with custom services in x++
Your export method returns the image as string (with binary data encoded to string with Base64).
If you want the same approach on import, the type of the parameter must be string, not Bitmap. You'll then use something like BinData::loadFromBase64() to convert the string to binary data.
Post and update person image with custom services in x++
Yes, I know about the service and created the service class with the accepting a string parameter method for a return person image, and it's working fine with Postman.
My service operation method code is
public str getEmployeeImage(HcmPersonId _Id)
{
HcmPersonImage personImage;
bindata bin = new bindata();
str content;
container image;
select personImage where personImage.Person == HcmWorker::findByPersonnelNumber(_Id).Person;
image = personImage.Image;
bin.setData(image);
content=bin.base64Encode();
return content;
}
Now I want to upload or update the image from Postman or the mobile app
here is my code for uplaod image
public void uploadEmployeeImage(Bitmap _image, HcmPersonRecId _personId)
{
HcmPersonImage personImage;
Post and update person image with custom services in x++
But it's not clear what you want us to show you.
Please answer: do you know how to create a custom service accepting a single string parameter?
If not, you're looking for basics of custom services; you're not yet in a situation to implement anything about images. That will come later.
If you know how to create a custom services, giving you examples of that would be useless for you and a waste of time for us. It would mean that you're actually struggling with something else, but it's not clear what it is unless you write it down.
Post and update person image with custom services in x++
Hi Martin,
I am very grateful to you for your quick response.
sorry for the misunderstanding I do not want to develop the whole thing for myself. I just want if you any any articles or code examples to share with me for help.
Martin Dráb230,371Most Valuable Professional
on at
Post and update person image with custom services in x++
Aha, you want me to develop the whole thing for you. Sorry, I'm not going to do it. I'm willing to answer your question but not doing your work for you. I don't even have time for that.
Maybe you should simply use the data entity instead of trying to implement a custom solution for the same thing, if you're unable to do it.
And if you insist, either use my suggest or design a different solution, e.g. use a string parameter with the image encoded with Base64. It'll likely be easier for you than dealing with binary data directly.
Choose the solution that suits you the best and try to implement. If you have no idea how to do it, e.g. how to use the data entity or how to create a trivial custom service, check out documentation and ask questions here if needed.
Then start the implementation. For example, if you decided to use a custom service, create a simple service just accepting a parameter (without processing the data for now) and test that you can call it. Ask questions if you get into problems.
Post and update person image with custom services in x++
What do you want the example to show? Are you saying that you tried to follow my suggestion ("For example, you could have a service operation accepting a party number and System.Byte[] object") and you ran into a problem?
Post and update person image with custom services in x++
Thanks Martin for quick response.
Can you share code examples for the custom service?
I am your response Martin.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.