I'm using spring ws 2.0.2.RELEASE
I have a web service that creates a sales order
Two of the elements in the SOAP call are dates:
<ns3:requestedDate>2012-06-06T01:00:00.000+10:00</ns3:requestedDate>
<ns3:orderDate>2012-06-06T10:25:09.681+10:00</ns3:orderDate>
Both fields are defined in the schema as xs:dateTime
When I send through the SOAP call to my service I get:
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring xml:lang="en">Validation error</faultstring>
<detail>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-datatype-valid.1.2.1: '2012-06-06T01:00:00.000+10:00' is not a valid value for 'date'.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-type.3.1.3: The value '2012-06-06T01:00:00.000+10:00' of element 'ns3:requestedDate' is not valid.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-datatype-valid.1.2.1: '2012-06-06T10:25:09.681+10:00' is not a valid value for 'date'.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-type.3.1.3: The value '2012-06-06T10:25:09.681+10:00' of element 'ns3:orderDate' is not valid.</spring-ws:ValidationError>
</detail>
</SOAP-ENV:Fault>
Any idea why these valid dates are being reported as invalid by Spring?
It seems if I pass in just the date portion '2012-06-06' it all works. I suppose the clue here should have been 'date' as opposed to 'datetime'. The end point being called must be expecting only a date.
Probably the date format. It's parsing the date in the format YYYY-MM-DD but a lot of validators pass what is basically the universally accepted internet format of DD-MM-YYYY. Had similar trouble recently with validating a form in mobile safari. Try changing the date format and see if that works.
Related
I am using the Mailchimp API to add a new member.
I have defined a custom merge field called ADDED which is the date I added this member to the list. I want this field to be required when submitting it via the API. I defined it as DD/MM/YYYY format (see below):
This is what my json string looks like:
{
"email_address":"email#server.com",
"status":"subscribed",
"merge_fields":
{"USERLEVEL":"1", "BATCH":"999000", "ADDED":"21/04/2020"}
}
As you can see, my format is indeed `dd/mm/yyyy', but when submitting the API request, I get this error message:
**Your merge fields were invalid: Please enter the date**
{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title":"Invalid Resource","status":400,
"detail":"Your merge fields were invalid.",
"instance":"1ad6bc0e-7728-45c1-a308-b751247efb5b",
"errors":[{"field":"ADDED","message":"Please enter the date"}]}
Can anyone explain why I am getting this error, when I do seem to have the correctly formatted date in the request?
Thanks.
OK, it seems that the definition of the field as DD/MM/YYYY might only be for reading purposes. but for submitting, it must be done like this:
"ADDED":"2020-04-21T00:00:00.001Z"
I am working on a Jmeter LDAP test plan and the test plan has to populate an attribute on the LDAP that is multi-valued.
When I do an LDAP search sampler, I noted that the value I get back is a string, with the values separated by ", ".
But, if I take the same comma-separated string and try to do an LDAP modify or add, using either an LDAP Request or LDAP Extended Request, I get an error.
So I am wondering if there is a way that the Jmeter LDAP Request or LDAP Extended Request can do that?
Thanks,
Jim
EDIT: When I try to use an Extended LDAP Request modification test/add with the attribute of "", I get this error in the Jmeter GUI response:
When attempting to modify entry cn=xxx... to replace the set of values for attribute lastlogindate, value "20181023085627-04, 20181024063205-04" was found to be invalid according to the associated syntax: The provided value "20181023085627-04, 20181024063205-04" is not a valid generalized time value because it contains an invalid character '-' at position 14
The strange part is that even though I have Jmeter to log at debug level, I don't see any detail on the error in the Jmeter.log, but/so I am guessing that that error message is coming from the Jmeter client itself. I noticed that the message says:
to replace the set of values
so it seems like it recognizes that I am trying to modify/replace a multi-value, but it doesn't seem to like the syntax of the replacement values string(s).
Does anyone know what the correct format SHOULD be?
I found the answer to my own question, or at least "A" answer: It appears that I can use an Extended LDAP request, and add the same attribute in that request, multiple times. So for example, if I am populating an attribute named "foo" the Extended LDAP request would have the following:
attribute value opcode
foo 12345 add
foo 12346 add
etc.
I think I also need to do a replace with no value, to empty the attribute, before all the adds.
I have a Django Rest Framework serializer with a DateTimeField. By default it will deserialize date/time values using the iso-8601 format. However, iso-8601 doesn't require a timezone offset. I need the user to always provide some timezone offset information (or better said, validate agains rfc 3339, a subset of iso-8601).
The field allows you to set a custom list of input_formats, but since Python is unable to parse rfc 3339 formatted dates correctly (i.e. an offset with a colon between the hour and minute part is unsupported) I'm stuck.
The DateTimeField in Django Rest Framework is perfectly capable of parsing rfc 3339 datetime values thanks to it's use of django.utils.dateparse.parse_datetime (it's somewhat more lenient, but that's fine).
parse_datetime either returns a timezone aware datetime instance (with tzinfo zet to a fixed offset) or a naive datetime instance (no tzinfo).
Django Rest Framework's DateTimeField converts any given value to an aware datetime value if settings.USE_TZ is set or the field was given a value for the default_timezone argument, otherwise any value is made naive.
The enforce_timezone method of DateTimeField is responsible for making values aware/naive.
Knowing this, enforcing that parsed values must be timezone aware can be achieved by overriding enforce_timezone and raising a ValidationError if the parsed datetime value is naive:
from django.utils import timezone
class DateTimeFieldWithOffset(serializers.DateTimeField):
default_error_messages = {
'naive': 'Datetime value is missing a timezone offset.'
}
def enforce_timezone(self, value):
if timezone.is_naive(value):
self.fail('naive')
return super().enforce_timezone(value)
I have a WebApi project where I have a method that takes a start date and an end date, runs a report, and returns the results. I'm trying to come up with the route for this and so far its looking like
/api/MarketingEmailStatisticsReports/DateRange/{startDate}/{endDate}
Perhaps there is a better route but that really isn't the problem.
I was testing this by simply opening a browser and typing the URL. If I set the startDate and endDates as DateTime fields, I get a 404 Not Found. If I make them strings, I can enter the method but the dates aren't parsable when I attempt to convert them from strings to actual DateTime values.
I realize that if I use "/" characters in the date that will be a problem so I did attempt to use "-" characters as the separator between the month-day-year values.
After looking at some of the Microsoft documentation, I saw how you can put route constraints to check for a DateTime values as well as a regular expression to make sure the value was entered in the correct format. I have taken this advice and am using the following:
[HttpGet]
[ResponseType(typeof(MarketingEmailStatisticsReport))]
[Route("/api/MarketingEmailStatisticsReports/DateRange/{startDate:datetime:regex(^\\d{4}-\\d{2}-\\d{2}$)/{endDate:datetime:regex(^\\d{4}-\\d{2}-\\d{2}$)}")]
public IHttpActionResult Get(DateTime startDate, DateTime endDate)
I get this exception:
ArgumentException: parsing
"^\d{4}-\d{2}-\d{2}$)/{endDate:datetime:regex(^\d{4}-\d{2}-\d{2}$" -
Too many )'s.
This is the URL I was using:
api/MarketingEmailStatisticsReports/DateRange/2017-05-22/2017-05-23
It doesn't look to me that I have too many ")" characters... What do I need to do to get this to work, or should I pass the dates on the querystring instead?
You forgot to close startDate parameter definition:
.../DateRange/{startDate:datetime:regex(^\\d{4}-\\d{2}-\\d{2}$)}/{endDate:datetime...
^
this curly bracket
I have a ruby model that contains a date attribue which I'd like to be able to pass in as a parameter in the format dd/MM/yyyy.
However, my sqlite3 db stores the data in yyyy-MM-dd format so when a date like 20/10/2010 gets passed in, it will not be read to the database.
I am using the Sinatra framework and using haml for the markup creation.
Do I need to write a helper that takes the date string and converts it to the correct format for the db? Or can I set a format type on the models attribute?
Thanks.
You shouldn't need to worry about the database's internal representation of the date; DataMapper is there to do that for you. You just need to make sure you are passing it a valid Date object.
Check out http://ruby-doc.org/core/classes/Date.html for methods available to the Date class. For your example:
require 'date'
mydate = '20/10/2010'
mydate_obj = Date::strptime(mydate, '%d/%m/%Y')
puts "#{mydate_obj}" # prints 2010-10-20
I don't know if this can help, some time ago I had the same problem: I was using Rack::Utils.escape_html(params[:datetime]) to escape html on user input and if I typed a date in a form field like this "25/02/2013" it would be sent to the DataMapper model like this: 16/02/2013 (with escaped html codes) so it was saving it the wrong way (day ended up being the hour or something similar).
Maybe you are also using "escape_html" method in an awkward way?