[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] Rif: Re: Rif: Re: In: Re: In: HTTPAPI - Example 7 - Upload a file from IFS - No file attached!



Hi Sara,

I see what IBM is saying.   In your call to http_mfd_encoder_addstmf() you are telling it that the document is named 'Certificate'.   However, in the IBM curl examples, it is named 'content'.

Here is the curl command with some line-feeds added to make it easier to read:

curl -X POST "https://sandbox.food.ibm.com/ift/api/documents/v1/documents"
  -H "accept: application/json"
  -H "Authorization: Bearer <token>"
  -H "Content-Type: multipart/form-data"
  -F "properties={"documentType": "Generic Document","documentTitle": "UOVA OVI BIO X6-Lotto 1588-20210609","issueDate": "2021-06-09","epcList":["urn:epc:class:lgtin:8054729.020969.1588"]}"
  -F "entitlement={"entitlementMode": "private",  "entitledOrgIds": []}"
  -F "content=@Certificato.pdf;type=application/pdf"

I think the line-feeds help, you can see that it is adding 3 headers with -H, and you are doing this in HTTPAPI as well.  They are also specifying 3 variables in the multi-part form data (MFD) named 'properties', 'entitlement' and 'content'.

However, in your RPG code you are doing this:

    http_mfd_encoder_addvar_s(enc: 'properties'  : $properties);
    http_mfd_encoder_addvar_s(enc: 'entitlement'  : $entitlement);
    http_mfd_encoder_addstmf( enc
                            : 'Certificate'
                            : $file_path
                            : 'application/pdf');

IBM's are 'properties', 'entitlement' and 'content', but yours are 'properties', 'entitlement' and 'Certificate', so aren't the same.

-- 
Scott Klement
sk@xxxxxxxxxxxxxxxx

On 6/25/2021 11:34 AM, SaraBellucci@xxxxxxxxxxxxxxxxx wrote:
Hi Scott,
Thanks for the explanation.

"You can send me the token privately if you wish, but I cannot promise to use it within an hour."
Yes, I know of course, and it's the reason why I told you that.
However I'll send you privately token just generated, so you can have 1 hours to use it.

I modified the program in this way:
  if http_mfd_encoder_addstmf( enc
                            : 'Certificate'
                            : $file_path
                            : 'application/pdf') = *off;
     msg = http_error();
  endif;

With debug, I put the breakpoint in the specific "msg = http_error()", and it weren't stopped in this specific.
And "msg" is empty.

"You say that you are receiving an HTTP 201 response code"
Yes, I receive the 201 return code as anything goes well... but the pdf is not attached in the document list.
I try to explain what I mean with some screenshot.

This is a document sent with another procedure, called swagger.
And this have the PDF attached as you see.


And this one instead, sent with my RPG program doesn't have the PDF attached:



But in the document library there are both document  listed.


I hope that helps you.
Thank you very much.

_________________________________________________________
Sara Bellucci

SAS INFORMATICA srl

Tel: +39 075 5058160
Fax: +39 075 5058105
e-mail: SaraBellucci@xxxxxxxxxxxxxxxxx
http://www.sasinformatica.it



Da:        "Scott Klement" <sk@xxxxxxxxxxxxxxxx>
Per:        ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Data:        25/06/2021 17:34
Oggetto:        Re: [Ftpapi] Rif: Re: In: Re: In: HTTPAPI - Example 7 - Upload a file from IFS - No file attached!
Inviato da:        ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx




Hi Sara,
You can send me the token privately if you wish, but I cannot promise to use it within an hour. 
You should check the return value from the subprocedure.  http_error() always returns the most recent error that has occurred, so if there is no error it may return an unrelated error message that occurred somewhere else in the job.  Only call it when the return value indicates that the procedure was unsuccessful.
  if http_mfd_encoder_addstmf( enc
                            : 'Certificate'
                            : $file_path
                            : 'application/pdf') = *off;
     msg = http_error();
  endif;

You say that you are receiving an HTTP 201 response code.  Any 2xx code indicates success, so it would appear your transaction is working.  You mention that the 'document is not found in the document library', and I don't know what that means -- this sounds like it is something that is particular to this API.  Unfortunately, I am not familiar with this API.
--
Scott Klement
sk@xxxxxxxxxxxxxxxx


On 6/25/2021 9:19 AM, SaraBellucci@xxxxxxxxxxxxxxxxx wrote:
Hi Scott,
sorry if I reply to you privately, but I have to tell you that I can give you a token, but it is valid only for 1 hours, if I remember correctly, or 3 hours at most.
So you have to do test it immediately...


However I try to add the http_errors() after calling http_mfd_encoder_addstmf() in this way.

Is it correct?


  http_mfd_encoder_addstmf( enc

                            : 'Certificate'

                            : $file_path

                            : 'application/pdf');

    msg = http_error();                                


And the msg variable is empty. I don't know if it is sign of error or not.


Debug is *ON.
I receive the 201 return code.

In the result file I receive correctly the response of the ID of the document sent.

But the document in the document library thre isn't.

 



_________________________________________________________
Sara Bellucci

SAS INFORMATICA srl

Tel: +39 075 5058160
Fax: +39 075 5058105
e-mail:
SaraBellucci@xxxxxxxxxxxxxxxxx
http://www.sasinformatica.it



Da:        
"Scott Klement" <sk@xxxxxxxxxxxxxxxx>
Per:        
ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Data:        
25/06/2021 07:19
Oggetto:        
Re: [Ftpapi] In: Re: In: HTTPAPI - Example 7 - Upload a file from IFS - No file attached!
Inviato da:        
ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx




Hello Sara,
I'm only able to look at your code with my eyes, I am unable to load it, run it, or debug it since I don't have your bearer token or PDF file.  
Looking at it, it seems okay?
I notice that you are not checking for errors when calling http_mfd_encoder_addstmf().  Is it possible that this is reporting an error, and this is going unnoticed?
Have you created a debug/trace file and looked inside of that?

--
Scott Klement

sk@xxxxxxxxxxxxxxxx
On 6/24/2021 2:07 AM,
SaraBellucci@xxxxxxxxxxxxxxxxx wrote:

In this case I don't receive the error "No file attached!", but there is something strange.

In the document list of the IBM food trust library, I find the document as a title, but when I try to view the detail and open the PDF file, I don't find the document.

It seems the same result... that the file was not attached in fact.

Can you help me, please?

--
_______________________________________________
Ftpapi mailing list

Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi


--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi



-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi