369
Views
9
Comments
Solved
date time format YYYY-MM-DDThh:mm:ss.sTZD rest api post
Question

Hi!


I'm trying to post a rest api request with field in text format of datetime YYYY-MM-DDThh:mm:ss.sTZD, but i keep getting erro 400 bad request due to the timezone not being filled.


I'm sending request to SIBS API.


in my logs there is the following info:


400 400

   at sseConsulta1.CcTestOppwa2.ActionPostPayments(HeContext heContext, ICcTestOppwa2Callbacks _callbacks, String inParamAuthorization, String inParamentityId, String inParamamount, String inParamcurrency, String inParampaymentType, String inParampaymentBrand, String inParammerchantTransactionId, String inParamip, String inParamsurname, String inParamgivenName, String inParamcountry, String inParamshopperResultUrl, String inParamcustomParametersSIBSMULTIBANCO_PtmntEntty_, DateTime inParamcustomParameters_SIBSMULTIBANCO_RefIntlDtTm_, DateTime inParamcustomParameters_SIBSMULTIBANCO_RefLmtDtTm_, String inParamContentType, STPostPaymentsResponseStructure& outParamResponse)POST https://test.oppwa.com/v1/payments HTTP/1.1

User-Agent: OutSystemsPlatform

Content-Type: application/x-www-form-urlencoded

Authorization: [redacted]

Host: test.oppwa.com

Content-Length: 531


entityId=8ac7a4c879466f8e017953551b9d1246&amount=10.00¤cy=EUR&paymentType=PA&paymentBrand=SIBS_MULTIBANCO&merchantTransactionId=ABC12345&customer.ip=213.58.172.221&customer.surname=JOHN&customer.givenName=DOE&billing.country=PT&shopperResultUrl=https%3a%2f%2fsibs.docs.onlinepayments.pt%2ftutorials%2fserver-to-server&customParameters%5bSIBSMULTIBANCO_PtmntEntty%5d=23867&customParameters%5bSIBSMULTIBANCO_PtmntEntty%5d=2022-02-04T23%3a16%3a10.161Z&customParameters%5bSIBSMULTIBANCO_RefLmtDtTm%5d=2022-02-04T23%3a16%3a10.161Z


HTTP/1.1 400

Strict-Transport-Security: max-age=63072000; includeSubdomains; preload

X-Content-Type-Options: nosniff

X-XSS-Protection: 1; mode=block

Pragma: no-cache

X-Application-WAF-Action: allow

Vary: Accept-Encoding

Connection: close

Content-Length: 906

Cache-Control: private, no-cache, no-store

Content-Type: application/json;charset=UTF-8

Date: Fri, 04 Feb 2022 23:16:04 GMT

Set-Cookie: JSESSIONID=DB60D8FA21F64BBC5F739A629163D781.uat01-vm-tx04; Path=/transaction; Secure; HttpOnly;Secure

Server: ACI


{"id":"8ac7a4a07ec4ee3f017ec705fd722fc4","paymentType":"PA","paymentBrand":"SIBS_MULTIBANCO","amount":"10.00","currency":"EUR","descriptor":"USAGE","merchantTransactionId":"ABC12345","result":{"code":"200.100.103","description":"invalid Request Message. The request contains structural errors"},"resultDetails":{"ExtendedDescription":"SIBSMULTIBANCO_RefIntlDtTm is missing or wrongly formatted","AcquirerResponse":"SIBSMULTIBANCO_RefIntlDtTm is missing or wrongly formatted"},"customer":{"givenName":"DOE","surname":"JOHN","ip":"213.58.172.221"},"billing":{"country":"PT"},"customParameters":{"SIBSMULTIBANCO_PtmntEntty":"23867,2022-02-04T23:16:10.161Z","SIBSMULTIBANCO_RefLmtDtTm":"2022-02-04T23:16:10.161Z"},"buildNumber":"5b956e5e3ef1

...

UserImage.jpg
jorge cardoso
Solution

Simply by adding a string "%2B" for the urlencode to replace to + works

without your help with that function i wouldn't have done


2024-01-31 05-29-41
Akshay Deshpande

Hello jorge,

I am not sure but the problem related with UI outsystem YYYY-MM-DDThh:mm:ss.sTZD  due to its passing extra T in the format. see the relevant post for the same

https://www.outsystems.com/forums/discussion/75732/date-time-is-showing-with-extra-t/

may be solution :- using substr or something pass the correct date "YYYY-MM-DD hh:mm:ss"

Thanks and Regards,

Akshay Deshpande

2020-01-08 08-43-00
Rahul Kumar

Hi jorge cardoso,

You are getting 400 (Bad request) error. 

Because API is expecting value in this YYYY-MM-DDThh:mm:ss.sTZD format.


I checked the SIBS APIs, values are like this 

"2020-07-15T12:10:49.131+01:00"


So, You have to add timezone in your formatted date time. 

Use FormatDateTime outsystems function and add timezome after it. 

FormatDateTime(CurrDateTime(),"yyyy-MM-ddThh:mm:ss.sss")+timezome


How to get timezone -

To get the timezone, use below Javascript to get time zone offset.


Check - Test Screen


Please check the attached OML file. 

Regards,

Rahul Kr.

Demo_DT.oml
UserImage.jpg
jorge cardoso

I've tested with does the string correctly however when post the plus sign of the timezone is replaced by white space


400

   at sseConsulta1.CcTestOppwa2.ActionPostPayments(HeContext heContext, ICcTestOppwa2Callbacks _callbacks, String inParamAuthorization, String inParamentityId, String inParamamount, String inParamcurrency, String inParampaymentType, String inParampaymentBrand, String inParammerchantTransactionId, String inParamip, String inParamsurname, String inParamgivenName, String inParamcountry, String inParamshopperResultUrl, String inParamcustomParametersSIBSMULTIBANCO_PtmntEntty_, String inParamcustomParameters_SIBSMULTIBANCO_RefIntlDtTm_, String inParamcustomParameters_SIBSMULTIBANCO_RefLmtDtTm_, String inParamContentType, STPostPaymentsResponseStructure& outParamResponse)POST https://test.oppwa.com/v1/payments HTTP/1.1

User-Agent: OutSystemsPlatform

Content-Type: application/x-www-form-urlencoded

Authorization: [redacted]

Host: test.oppwa.com

Content-Length: 547


entityId=8ac7a4c879466f8e017953551b9d1246&amount=10.00¤cy=EUR&paymentType=PA&paymentBrand=SIBS_MULTIBANCO&merchantTransactionId=ABC12345&customer.ip=213.58.172.221&customer.surname=JOHN&customer.givenName=DOE&billing.country=PT&shopperResultUrl=https%3a%2f%2fsibs.docs.onlinepayments.pt%2ftutorials%2fserver-to-server&customParameters%5bSIBSMULTIBANCO_PtmntEntty%5d=23867&customParameters%5bSIBSMULTIBANCO_PtmntEntty%5d=2022-02-05T10%3a26%3a55.5555+00%3a00&customParameters%5bSIBSMULTIBANCO_RefLmtDtTm%5d=2022-02-05T10%3a26%3a55.5555+00%3a00


HTTP/1.1 400

Strict-Transport-Security: max-age=63072000; includeSubdomains; preload

X-Content-Type-Options: nosniff

X-XSS-Protection: 1; mode=block

Pragma: no-cache

X-Application-WAF-Action: allow

Vary: Accept-Encoding

Connection: close

Content-Length: 918

Cache-Control: private, no-cache, no-store

Content-Type: application/json;charset=UTF-8

Date: Sat, 05 Feb 2022 10:26:50 GMT

Set-Cookie: JSESSIONID=38CC426C38AA7338F183F495B167F7DF.uat01-vm-tx02; Path=/transaction; Secure; HttpOnly;Secure

Server: ACI


{"id":"8ac7a4a27ec4ee42017ec96c15783d24","paymentType":"PA","paymentBrand":"SIBS_MULTIBANCO","amount":"10.00","currency":"EUR","descriptor":"USAGE","merchantTransactionId":"ABC12345","result":{"code":"200.100.103","description":"invalid Request Message. The request contains structural errors"},"resultDetails":{"ExtendedDescription":"SIBSMULTIBANCO_RefIntlDtTm is missing or wrongly formatted","AcquirerResponse":"SIBSMULTIBANCO_RefIntlDtTm is missing or wrongly formatted"},"customer":{"givenName":"DOE","surname":"JOHN","ip":"213.58.172.221"},"billing":{"country":"PT"},"customParameters":{"SIBSMULTIBANCO_PtmntEntty":"23867,2022-02-05T10:26:55.5555 00:00","SIBSMULTIBANCO_RefLmtDtTm":"2022-02-05T10:26:55.5555 00:00"}

2020-01-08 08-43-00
Rahul Kumar

It would be problem of data type, make sure you are holding timezone value in text data type local variable.

Check the data type of Javascript output parameter, It should be text. 

FormatDateTime(CurrDateTime(),"yyyy-MM-ddThh:mm:ss.sss")+timezome

It is just concatenation of two string.

 

 

UserImage.jpg
jorge cardoso

Correct. I ve tested your oml works fine but due to the API submission is urlencoded the plus sign is supresssed by the whitespace.



2020-01-08 08-43-00
Rahul Kumar

You have to pass, whole vlaue "2022-02-05T07:56:01.011+05:30" , how api will replace + sign with whitespace.

Please share your oml if possible.

UserImage.jpg
jorge cardoso

I Will submit the file on the Next 8hours. Out of office

UserImage.jpg
jorge cardoso
Solution

Simply by adding a string "%2B" for the urlencode to replace to + works

without your help with that function i wouldn't have done


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.