Closed maxbale closed 2 years ago
I tried to reproduce your error and I didn't get any exception. Can you give the entire stack trace of the exception?
Message: Parametro(i) non valido(i): after, before
RequestData: {WordPressPCL.Models.BadRequest}
RequestData.Data: {{
"status": 400,
"params": {
"after": "Data non valida. ",
"before": "Data non valida. "
},
"details": {
"after": {
"code": "rest_invalid_date",
"message": "Data non valida. ",
"data": null
},
"before": {
"code": "rest_invalid_date",
"message": "Data non valida. ",
"data": null
}
}
}}
RequestData.Name: rest_invalid_param
StackTrace:
in WordPressPCL.Utility.HttpHelper.1.MoveNext() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
in LctIntA2w.foInterface.
Thank you
After
and Before
represent the parameters to limit the search for media items. Are you by chance setting the After
and Before
for MediaQueryBuilder
? If not, then it may be possible that this might have happened due to Locale settings difference. Would you mind telling me what is CultureInfo.CurrentCulture
in your program? Also, could you evaluate DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ss")
and tell what it gives as output? Also, if you add CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
at the start of the program does the problem go?
Thank you very much! I didn't set Before and After parameters in the MediaQueryBuilder but my CultureInfo.CurrentCulture (it-IT) caused the exception. Setting CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); solved the trouble
This is a bug and I will issue a fix PR for this.
Hi, I'm using the following code to search a media by filename:
string stImageName ="myimage.jpg"; var queryBuilder = new MediaQueryBuilder(); queryBuilder.PerPage = 1; queryBuilder.Page = 1; queryBuilder.MediaType = MediaQueryType.Image; queryBuilder.Search = stImageName;
var queryresult = await wpClient.Media.Query(queryBuilder);
but I obtain the following exception: "Parametro(i) non valido(i): after, before" Can someone help me? Thanks
WordPressPCL version: 1.9.0 WordPress version 5.8.2