Strapi routes return 404 Not found - docker

I have a problem where all routes in my API return 404 Not found. I followed the Pull from Docker Hub section at strapi/strapi-docker.
What I did, apart from running the images, was creating a new Content type called post containing three fields. If I try GET /post (to get all posts added) I get unauthorized response error. This is expected at this stage. After I check Roles & Permissions to allow the Public role to use the find and findOne routes I instead get a 404 Not found response error even though data has been added.
The dev server does not use any prefix.
post routes for find and findOne looks as the following:
{
"routes": [
{
"method": "GET",
"path": "/post",
"handler": "Post.find",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/post/:_id",
"handler": "Post.findOne",
"config": {
"policies": []
}
}
}
There are not many options in the strapi interface to fiddle with so I'm not sure what else to try. I have tried a couple of other installations of strapi. Not sure if that could have messed it up but I vaguely remember trying out strapi/strapi-docker before and getting it to work.

I have stumbled upon this issue many times, and the easiest answer usually is:
Have you published any of your posts?
Strapi has a publishing subsystem which is usually turned on upon the creation of any collection, single type or component.
So when you create any content of any created type, the data is saved as draft and is not publicly available.
Here is my link collection type. It is saved, but not published.
So if you are trying to test an endpoint, but you only have one single data entry and it is set to draft, no data will show up.
No data!
In case of a single type that is not published
This will return a 404!
Publish and, voila ...
This could be one reason why strapi is sending you a 404 or only an empty array!

I've had this issue many times as well, even with published content.
Two additional causes could be:
if your content type is posts try /posts as well as /api/posts (the 2nd usually works for me
Under Settings > Roles (the one under USERS & PERMISSIONS plugins) make sure both Authenticated and Public user roles have find and findOne access to the content type.
One time I was getting the 404 even though I did this for Public...but because I was in the same browser as my logged in admin and needed to update it for Authenticated as well.

Related

SendGrid API - Cannot use dynamic template data with a legacy template

Trying to follow the sample here https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-templates,
I'm sending the following JSON to this url: "https://api.sendgrid.com/v3/mail/send" (and I have sent a simple email before using the same code, now I want to try a template with substitution):
{
"personalizations": [
{
"subject": "Test template email from SendGrid",
"to": [
{
"name": "Neal Walters",
"email": "myRecipient#example.com"
}
],
"dynamic_template_data": {
"Applicant_Name": "John Doe",
"Send_Date": "December 30, 2022"
}
}
],
"from": {
"name": "NealWalters(SendGrid)",
"email": "mySender#example.com"
},
"template_id": "bcab1b12-d922-4cdd-b6f5-9f39b16d9823"
}
and getting this cryptic error:
{"errors":[{"message":"Cannot use dynamic template data with a legacy template
ID","field":"personalizations.0.dynamic_template_data","help":null}]}
I have no idea what is a dynamic nor a legacy template. I copied one of Send Grid's demo templates (Nonprofit Newsletter Email Template) and added some of my own tags.
When I used the template name ("NealDemo Duplicate Nonprofit Newsletter Email Template") instead of the GUID (which I got from the URL when I was editing the template), the message was similar but added this to the above error - which leaves me with the question of can I use the template name or not? It's unclear what a "template_id" is on how to find it, if it is not the name of the template as I saved it.
{"message":"The template_id must be a valid GUID,
you provided 'NealDemo Duplicate Nonprofit Newsletter Email Template'.","field":"template_id","help":"http://sendgrid.
com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.template_id"},{"message":"Unless a valid template_id is
provided, the content parameter is required. There must be at least one defined content block. We typically suggest
both text/plain and text/html blocks are included, but only one block is required.","field":"content","help":"http://s
endgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content"}]}
Disappointed these are not listed on this errors page:
https://docs.sendgrid.com/api-reference/mail-send/errors
Are there two template editors?
I used this one:
https://mc.sendgrid.com/design-library/your-designs/bcab1b12-d922-4cdd-b6f5-9f39b16d9823/editor
I didn't see any other guid/id for the template, so I tried "bcab1b12-d922-4cdd-b6f5-9f39b16d9823" from the URL.
But now I see there is also a dynamic template editor???
https://mc.sendgrid.com/dynamic-templates
As mentioned below, I copied one of your demo templates, which already had some substitution variables in at the bottom ({{Sender_Name}}
{{Sender_Address}}, {{Sender_City}}, {{Sender_State}} {{Sender_Zip}}). I just added two of my own at the top.
I have referenced this: Getting "Cannot use dynamic template data with a legacy template" with non-legacy template
The saga continues. I went to this page: https://mc.sendgrid.com/dynamic-templates and was able to copy over my previous template, so perhaps it was a legacy template. It now gave it a clearly labeled template-id of: d-a35d9d48ce304588bbebf7828811b473 (which looks like a "d-" followed by a guid).
I ran that through the API call, which resulted in no immediate errors, but then I got this email:
Usually when I can't figure things out, it is either the documentation is lacking, or I was speed-reading it.
When I first setup my account, I apparently clicked a link that took me to SendGrid's main site, and I signed up for an account there. Apparently this step was totally unnecessary (also their site requires a 2FA, separate from Azure). So I built my templates on their site, which was under a different account then the one I created in Azure. Thus I was able to send emails with the token from Azure, but any time I tried to send a template from my second account, of course, it was not recognized with my Azure account.
You can create templates inside of Azure, from the links shown below:
Then this:
NOTE 1 - their "pretty" designs are still under the Legacy Templates, and "Dynamic Templates" seem to be the newer preferred way to go. You can build a "legacy template", then apparently copy it's HTML over to a "dynamic template".
NOTE 2 - I only solved this by opening a support ticket with SendGrid.

OneM2M, IOTKETI Mobius RETRIEVE Group Member ContentInstances

In my example architecture; I have an IN-Mobius and a ADN-AE-Thyme (nCube Thyme).
First of all; i created a AE which is called "ae_test_02", i can GET this resource via Postman.
After this step; i run ADN-AE-Thyme, thyme.js, and it created a container which is called "thyme_01", and also i can GET this resource via Postman.
Also in that step, thyme.js add containerInstances into the "thyme_01" container. Then, i can get that latest containerInstance with "/la" parameter via Postman
In this point, the problem has began. I create a group resource, while creating i tried couple solutions, always fail. I tried in "mid" attribute;
{ "m2m:grp": {
"rn": "grp_test_100520_08",
"mt": 3,
"mid": ["3-20200505012920476/la",
"Mobius/3-20200505012920476/la",
"Mobius/thyme_01/la",
"Mobius/ae_test_02/3-20200505012920476/la",
"Mobius/ae_test_02/thyme_01/la",
"ae_test_02/thyme_01/la",
"ae_test_02/3-20200505012920476/la"],
"mnm": 10
}
The problem is that, i tried these mid paths one by one, but never works. When i try to get latest containerInstances via Postman, i use this URL and the results is "resource does not exist (get_target_url)"
The containers and contentInstances in the IN-Mobius, and i requested to the IN-Mobius. By using these informations how should i implement group "mid" attribute; for the get containerInstances via group resources ?
First Edit.
Hi Andreas.
For the first issue, i can get resource correctly. In this point my aim is GET containerInstance in the container, which is a member (mid) in that .
Second; now I understand, there is not existing resource in resource, okay. As you mentined, i want to pass a request to all member (containers) of a resource. For this purpose, i will use https://localhost:7579/Mobius/grp_test_100520_08/fopt, but it gives an error "ERR_INVALID_ARG_TYPE". I know that, at least one mid structure is correct, but which one is the correct ?
For the smaller issue, i already know that resouce multiple times in the mid attribute, because i did not know which one is the correct adressing scheme ?
Also, while creating a resource, the resource should be in the ae resource (/Mobius/ae_test_02/grp_name) or in the Mobius (/Mobius/grp_name)
resources can be in directly in IN-Mobius or should in MN-Rosemary? Is fanOutPoint only using by external resource like MN or even IN, fopt using ?
Second Edit.
The "thyme" comes from nCube Thyme (https://github.com/IoTKETI/nCube-Thyme-Nodejs), it creates a container and then randomly create ContainerInstances.
The resource tree looks like;
Mobius >> ae_test_02 (AE resource) >> thyme_01 (Container It created from nCube Thyme https://github.com/IoTKETI/nCube-Thyme-Nodejs) >> ContainerInstances
I have also a resource in >> Mobius >> grp_test_100520_08 (GROUP resource which is uses)
I tried;
{ "m2m:grp": {
"mid": ["Mobius/ae_test_02/thyme_01"],
"mnm": 5
}
}
In this request, fopt.js gives an error "callback is not a function".
{ "m2m:grp": {
"mid": ["ae_test_02/thyme_01"],
"mnm": 5
}
}
In this request, fopt.js gives same "callback is not a function", but in different line.
I guess my fopt.js file is old, then i checked mobius github page and get that file, however it not solve this.
Also my resource look like this;
Also my fopt.js file is same as this;
https://github.com/IoTKETI/Mobius/blob/master/mobius/fopt.js
UPDATE 3.
The "cnm" attribute problem is this; while creating a resouce, CSE will automaticly assign "cnm" attribute according to member size. However, CSE will not this process in UPDATE (PUT) request. From this point, i will create resources, not UPDATE them.
As you mentioned, i send requests to the group's resource, but it gives the "callback is not a function" error. To solve this problem, i downloaded and installed the whole distribution. (https://github.com/IoTKETI/Mobius) After that, i will do same processes again for understand the fopt.js file behaviour. The result wasn't changed, it gives the same error.
I planning to explain whole situation and create an issue, in Mobius github page. I hope they will response soon.
I think there are two issues with your example.
The first issue is with the request to the <Group>. You need to distinguish between requests to the <Group> resource itself and requests to the members of the <Grou>.
There is no child resource <la> of the <Group> resource itself. This is why you receive an error message. If you want to pass a request to all members of a <Group> resource then you need to target the virtual child resource <fopt>. In your case the request should target URI https://localhost:7579/Mobius/grp_text_100520/fopt. Since you already have the <la> resources as members you won't need to add the /la part to the request. However, I would recommend to only add the <Container> resources to the group and use the target URI https://localhost:7579/Mobius/grp_text_100520/fopt/la to retrieve the latest <ContentInstances> of each container.
The second (smaller) issue is that from what I can get from your example code that you add the same resource multiple times to the group, but only with different addressing schemes. Please be aware that the CSE must removes duplicate resources when creating or updating the mid attribute.
Edit after question update
It is not very clear what your resource tree looks like. So, perhaps you should start with only one resource references and continue from there. Valid ID's in the mid attribute are either structured (basically the path of the rn attributes) or unstructured ID's (the ri's). The CSE should filter the incorrect ID, so you should get the correct set of ID's in the result body of the CREATE request.
btw, where does "thyme" come from? This is only in a label, which does not form an ID.
Regarding the <fanOutPoint> resource: Normally all request would be targeted to the <Group> resource, but requests to the virtual <fanOuPoint> resource are forwarded to al the members of the group. If a resource referenced in mid is accessible then the request is forwarded and the result is collected and is part of the result body of the original request.
You also need to be careful and regard the resource types: only send valid requests to the group's members.
Update 2
From the IDs in the mid attribute of the <Group> resource it looks like that the CSE validated the targets (though the cnm (current number of members) is obviously wrong, which seems to be an error of the CSE).
So, you should be able to send requests to the group's <fopt> resource as discussed above.
For the CSE runtime error you should perhaps contact the Mobius developers. But my guess is that you perhaps should download and install the whole distribution, not only a single file.
for anyone in the future; who is dealing with this problem.
The problem is simply is that; in the app.js there is 4 function call (fopt.check). While calling the function in the app.js file, there are 5 parameter exists, on the other hand, while getting these arguments in the function it takes only 4 arguments. For this reason, body_obj always becomes "undefined" then it will never reach the "Container" or "ContainerInstance" source. Lately, KETI was sent a new commit to the Mobius Github page (https://github.com/IoTKETI/Mobius/commit/950182b725d5ffc0552119c5c705062958db285f) to solve this problem. It solves this problem unless you are using use_secure == 'disable'. If you try to use use_secure == 'enable' you should add an if statement to check use_secure and add import HTTPS module.
Also, while creating resource, defining the "mid" attribute is not very clear. Just for now, if you want to reach (latest) source; you should add "/la" for all members of the group. This is recommended by KETI on Github page issue 5.
(https://github.com/IoTKETI/Mobius/issues/5#issuecomment-625076540)
And lastly, thank you Andreas Kraft; your help was very useful.

Is it possible to set permissions on variable groups via the REST API?

I was curious if anyone knows how to set permissions (add/remove groups) to variable groups via the REST API. I know there is the security namespace, however it requires a resource guid and I am not sure how to get that for a specific variable group?
You want security namespace "Library" ( you need to convert it to proper namespace_id ) and with token "Library/$project_id/VariableGroup/$variable_group_id"
POST https://dev.azure.com/{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=5.1
For ACL management REST API see https://learn.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20lists/set%20access%20control%20lists?view=azure-devops-rest-5.1
Example request:
"value": [
{
"inheritPermissions": true,
"token": "Library/$project_id/VariableGroup/$variable_group_id",
"acesDictionary": {
"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1204400969-2402986413-2179408616-0-0-0-0-1": {
"descriptor": "Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1204400969-2402986413-2179408616-0-0-0-0-1",
"allow": 31,
"deny": 0
}
}
}
]
Warning1 - At the moment the Microsoft doc on that topic is quite incomplete ( see, for example my comment on github issue asking for clarification of variables groups authentication mechanism ).
Warning2 - Be careful with ACL changing requests for ALL variable groups in project ( e.g. token=Library/$project_id/ ), because you might end up with removing permissions from all users on your Ado project and it's could be hard to change it back.
I am afraid it is not possible to set variable groups permission via api.
There is only group id we can get from variable group api below, no resource id in the response.
https://dev.azure.com/{organization}/{project}/_apis/distributedtask/variablegroups?api-version=5.1-preview.1
When i tried fetching the http request trace with F12 chrome. There is a value at the end of request url looks like the source id. And it is the project id combined with the variable group id. Donot know if this is resource guid you were looking for.
https://dev.azure.com//_apis/securityroles/scopes/distributedtask.variablegroup/roleassignments/resources/39e13f04-cb4e-4fa8-b2f1-0ee8f4fc82c5%241
I managed to reverse engineer who to do this. If anyone is curious on how it works feel free to talk a look at the powershell library for Azure DevOps I have put together -- https://github.com/ravensorb/Posh-AzureDevOps

Podio API - GET form

Looking for some help from an experienced Podio API navigator!
I'm trying to build a feature into our rails app where I can pull the details of a form from Podio, so that I can then automatically generate a form in our environemnt that can post to the app.
To do that I would need to get the category and labels of the fields..
However, when you GET a form from podio, this is all it gives you for the fields:
"fields": [
{
"field_id": foo,
"settings": null
},
{
"field_id": foo,
"settings": null
}
any thoughts on how I might use this information to get the information that I need? Can I somehow use the field_id to GET the field?
You can get the app and the fields within it by using GET request to,
/app/{app_id}/field/{field_or_external_id}

Asana tag API query often misses newly created Tags

when we create projects via API the newly created project is immediately returned in both the webApp and in the API.
But a tag created using API "https://app.asana.com/api/1.0/tags" is often returned only after two or three GET requests. Also in the webApp it needs a refresh, online application sync does not update new tags like Projects.
This late returns really affects the user interaction. I follow the same workflow thats used for creating and adding project, but tags feels a bit laggy. Am I missing anything?
The answer is that tags which aren't associated with any tasks are - unfortunately - hidden in the app, and consequently also in the API. As you discovered, you can get the ID back from the POST to create and then associate it with a task from there (since there's little purpose in creating a tag if you're not associating it with something that shouldn't typically be a problem, but it is clunky). We are looking at changing our data model for tags to be a bit more intuitive in future, but that's still a ways off, so this is the reality for the foreseeable future.
the newly created tag is missed in the GET /tags API from time to time. But the http response returned after creation of the new tag by POST /tags, will contain the id, name and other properties of the newly created tag. So we can add the new tag from this response.
POST-> https://app.asana.com/api/1.0/tags \
-u "name=fluffy" \
-u "workspace=14916"
# Response
HTTP/1.1 201
{
"data": {
"id": 1771,
"name": "fluffy",
...
}
}

Resources