First of all, thanks for reading this.
I've been racking my brains the whole morning as to why I'm getting a 400 Bad Request along with this error:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-1d24680c387efe1052e1dbc828a40b62-5b8bed004edfa9a9-00",
"errors": {
"notes": [
"The notes field is required."
]
}
}
I've removed all code, except for the return statement, all other parameters, yet still no luck.
My code is as follows:
[HttpPost("foo")]
public IEnumerable<bar> foo(string notes = "")
{
return Enumerable.Range(1, 1).Select(index => new bar
{
output = "Updated"
});
}
The request I'm sending is
https://localhost:7043/Update/?notes=
If my code is correct, this shouldn't be a problem since notes is optional, right?
Any help is appriciated, thank you :)
Related
Following the docs I've set up this handler inside routes():
this.put(
'/admin/features/error/environment/test',
// #ts-ignore
() => new Response(500, {}, { errors: ['The database went on vacation'] }),
);
Mirage does receive what I've set, sort of. Here is its response, from the browser console logs. Note that it's not an error although the 500 shows up in _bodyInit:
{
"type": "default",
"status": 200,
"ok": true,
"statusText": "",
"headers": {
"map": {
"content-type": "text/plain;charset=UTF-8"
}
},
"url": "",
"bodyUsed": false,
"_bodyInit": 500,
"_bodyText": "[object Number]"
}
Note that I need ts-ignore which is probably a clue. TS complains that new Response expects 0-2 arguments but got 3.
Try importing the Mirage Response class:
import { Response } from 'miragejs';
Otherwise, Response refers to a Fetch API Response object. This explains the type checking error and the unexpected behavior when calling the route.
After adding the import you can remove #ts-ignore and requests to the route should fail with status code 500.
I am running the following for our GA reporting v4 API - it works fine without the Ecommerce portion but once I add "ecommerce", it gave me an error.
def get_client_report(analytics):
return analytics.userActivity().search(
body=
{
"viewId": VIEW_ID,
"user": {
"type": "CLIENT_ID",
"userId": "REDACTED"
},
"activityTypes": [
"ECOMMERCE"
],
"dateRange": {
"startDate": "2020-04-02",
"endDate": "2020-04-02"
},
"ecommerce": {
"transaction": {
"transactionId" : "REDACTED"
}
}
}
).execute()
and I get the following error:
https://analyticsreporting.googleapis.com/v4/userActivity:search?alt=json returned "Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.". Details: "[{'#type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'description': 'Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.'}]}]">
Can you help me what is wrong here? Thank you!
your request body doesn't match the expected format. Take a closer look at docs.
only activityTypes field is supported and you cannot filter for a specific transactions ID. you'll have to perform filtering on your side after receiving a response in that case.
I am trying to create a new group and team via the Graph API. I am trying to run the POST a request in Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) as below but get a bad request.
Request: POST
Version: v1.0
URL: https://graph.microsoft.com/v1.0/teams/groups
Request Body:
{
"displayName":"Flight 157",
"mailNickname":"flight157",
"description":"Everything about flight 157",
"visibility":"Private",
"groupTypes":["Unified"],
"mailEnabled":true,
"securityEnabled":false,
"members#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
],
"owners#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
]
}
I get the below response error:
{
"error": {
"code": "BadRequest",
"message": "Invalid bind property name members in request.",
"innerError": {
"request-id": "fee10382-5112-44f8-a8c9-683453bdf050",
"date": "2020-03-05T01:08:19"
}
}
}
I am not quite sure what I am doing wrong. Can anyone please help me with this?
I need to update existing documents of a particular type with a new field. This new field should be set to the local day name of a date given by a datetime field in the document. The date time field is in the format yyyy-MM-dd'T'HH:mm:ss, is in UTC but has no explicit timezone code.
I'd like to do this with Groovy but have no Java experience. I'm guessing I need to:
1) Set the datetime to UTC locale
2) Convert to local locale (set to Europe/London) in this case
3) Get the day name from converted date and set new field (dayname) value with it
If I use the following update_by_query:
POST /myindex/_update_by_query
{
"script": {
"inline": "ctx._source.dayname = Some_function(ctx._source.datetime)"
},
"query": {
"term": {
"_type": "myDocType"
}
}
}
Is there a simple way to do this with a some Groovy functions (replacing Some_function above).
Any hints would be very much appreciated!
UPDATE - Thanks to tim_yates i have the following Sense console code:
POST /rating/_update_by_query
{
"script": {
"inline": "ctx._source.day = Date.parse(\"yyyy-MM-dd'T'HH:mm:ss\", ctx._source.datetime, java.util.TimeZone.getTimeZone('UTC')).format('EEEE', java.util.TimeZone.getTimeZone('Europe/London'))"
},
"query": {
"term": {
"_type": "transaction"
}
}
}
Unfortunately this generates the following error message:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "failed to run inline script [ctx._source.day = Date.parse(\"yyyy-MM-dd'T'HH:mm:ss\", ctx._source.datetime, java.util.TimeZone.getTimeZone('UTC')).format('EEEE', java.util.TimeZone.getTimeZone('Europe/London'))] using lang [groovy]"
}
],
"type": "script_exception",
"reason": "failed to run inline script [ctx._source.day = Date.parse(\"yyyy-MM-dd'T'HH:mm:ss\", ctx._source.datetime, java.util.TimeZone.getTimeZone('UTC')).format('EEEE', java.util.TimeZone.getTimeZone('Europe/London'))] using lang [groovy]",
"caused_by": {
"type": "missing_property_exception",
"reason": "No such property: java for class: 1209ff7fb16beac3a71ff2a276ac2225f7c4505b"
}
},
"status": 500
}
Though it does work if I remove reference to the getTimeZone - exact Sense console code as follows:
POST /rating/_update_by_query
{
"script": {
"inline": "ctx._source.day = Date.parse(\"yyyy-MM-dd'T'HH:mm:ss\", ctx._source.datetime).format('EEEE')"
},
"query": {
"term": {
"_type": "transaction"
}
}
}
I'm not sure why the getTimeZone method is failing. I've tried "TimeZone.getTimeZone" instead of "java.util.TimeZone.getTimeZone"
The Groovy code (for Java 7) you will need is going to be very similar to this:
Date.parse("yyyy-MM-dd'T'HH:mm:ss", ctx._source.datetime, TimeZone.getTimeZone('UTC'))
.format('EEEE', TimeZone.getTimeZone("Europe/London"))
OK, a bit more research allowed me to understand that tim_yates answer was correct, we just needed to whitelist the Java class required. We did this via:
nano $JAVA_HOME/lib/security/java.policy
and adding:
permission org.elasticsearch.script.ClassPermission "java.util.TimeZone";
...then restart the ES services.
Note this whitelists the class for all users, not just the ES user. See:
https://www.elastic.co/guide/en/elasticsearch/reference/2.2/modules-scripting-security.html
Following this tutorial as a guide (OData/EntityFramework/Asp.Net).
I'm able to execute a simple GET command on the root.
{
"#odata.context": "http://localhost:49624/$metadata",
"value": [
{
"name": "Appointments",
"kind": "EntitySet",
"url": "Appointments"
},
......
{
"name": "Clients",
"kind": "EntitySet",
"url": "Clients"
}
]
}
But anything more complex than that gives me an error message. (I'm using a null routePrefix.)
http://localhost:49624/Services
Gives me:
{
"Message": "No HTTP resource was found that matches the request URI 'http://localhost:49624/Services'.",
"MessageDetail": "No type was found that matches the controller named 'Services'."
}
Here's my super simple GET
[EnableQuery]
public IQueryable<Service> Get()
{
return db.Services;
}
If it matters I'm using Postman to test these commands. Although I imagine that is a non-factor.
I have a database & a DbSet for every table. I have no idea why I can't access any of this.
WebApiConfig:
config.MapHttpAttributeRoutes();
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Appointment>("Appointments");
builder.EntitySet<Service>("Services");
builder.EntitySet<Employee>("Employees");
builder.EntitySet<Client>("Clients");
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: null,
model: builder.GetEdmModel());
I'm sorry if this is a basic question but I'm really new to all this and have been at this wall too long already haha.
Jan Hommes above pointed out above that the controller class needs to be pluralized (In my case ServiceController -> ServicesController)