by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Daniel Corn
@cundd
Ah! I see! Nice :)
Jan Schröder
@Elektrobaer_twitter
it works exactly like create, only the __identity was missing
Thanks for the quick answer
Daniel Corn
@cundd
No problem! Thank you for having a look! Now I can steal your solution ;)
Daniel Corn
@cundd
How does the PropertyMapper handle the update? Does it replace the whole object, or only patch/change the sent properties?
Jan Schröder
@Elektrobaer_twitter
The propertymapper only updates the attributes you pass. Attributes that are not passed are not updated
$router->add(
            Route::patch(
                '/faq-rest/{int}/?',
                function (RestRequestInterface $request, $int) {
                    $arguments = [
                        'faqElement' => $request->getSentData(),
                    ];
                    $arguments['faqElement']['__identity'] = $int;

                    try {
                        return $this->helper->callExtbasePlugin(
                            'Faq', # extensionName
                            'XXX', # vendorName
                            'XXXFaq',# pluginName
                            'FaqElement', # controller
                            'updateRest', # action
                            $arguments
                        );
                    } catch (\TYPO3\CMS\Core\Exception $e) {
                        return $this->responseFactory->createErrorResponse(
                            $e->getMessage(),
                            400,
                            $request
                        );
                    }
                }
            )
        );
is this a nice way to Catch error ?
Daniel Corn
@cundd
Yes I think so. Or it could maybe be part of the Helper... inside public function callExtbasePlugin(...
when does it throw an error? If the original item doesn't exist?
Daniel Corn
@cundd
I pushed a commit with your update example: cundd/custom_rest@7a2804e
miguel
@miguel1995

Hello everyone.

I can call a POST service that I made and it works fine, I make the call when I use my application with my IP address and it works fine. But when I make the call from another domain name it doesn't work and I have the following message in the browser console.

Access to fetch at 'http: //xxx.xxx.xxx.21/circular/rest/eventos/search' from origin 'http://dev3.xxx.xxx.co' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

Can someone help me please?

This is my CORS setup:

plugin.tx_rest.settings {
responseHeaders {
Access-Control-Allow-Origin = *
Access-Control-Allow-Methods = GET, POST, OPTIONS, DELETE
Access-Control-Allow-Headers = Content-Type
}

}

Thanks
Jan Schröder
@Elektrobaer_twitter
@cundd I mean general errors, like when a wrong type is passed e.g. a string where an integer is expected.
Daniel Corn
@cundd
@miguel1995 most likely you are only missing the route for the OPTIONS request in your handler
The implementation in the CRUD handler e.g. only returns true resulting in a 200 response
mheilmeier
@mheilmeier
I have a general question: Is it possible to modify data? Say my client is sending {value: 1} to the backend and I want to increment "value" and save {value:2} to the DB? Thank you very much.
Daniel Corn
@cundd
@mheilmeier the best way to achieve this is with a custom DataProvider: https://rest.corn.rest/FAQ/#preprocess-input-data
Jan Schröder
@Elektrobaer_twitter
is there a easy way to catch params like GET http://beast.local/rest/page/?path=my/fancy/path
Daniel Corn
@cundd
The Rest Request implements https://www.php-fig.org/psr/psr-7/#15-server-side-requests. you could grab it from there
1 reply
getQueryParams() should give you the parsed query as array
mheilmeier
@mheilmeier
@cundd Thank you Daniel. Is it possible to use custom DataProviders to modify data when reading from DB too?
Daniel Corn
@cundd
Yes. Either the DataProvider or the Model itself if you have access to it (https://rest.corn.rest/FAQ/#customize-the-output-of-a-model)
Jennifer Eberlei
@jennifer.eberlei_gitlab

Morning

I am new to rest services and as a frontend developer definetly new on trying to implement them within typo3 can somebody maybe guide me?

I have a storage folder where I have several content elements. I want to call these content elements on a different page and have them formatted to json, so I can use the data within an angular view

So I was thinking about using the cundd/rest extension and sorry if I am wrong here, but I don't know where to go right now and any help would be highly appreciated
Daniel Corn
@cundd
Hi @jennifer.eberlei_gitlab that's a feature that's not implemented yet that way. It's part of the https://rest.corn.rest/_Initiatives/Headless/ which is currently looking for sponsors
Skeferstat
@Skeferstat
Hi, is there any c# example for consuming the rest api? Maybe an example for creating an user and the get his data? Thanks in advance!
Skeferstat
@Skeferstat

Hi,antoher question. For login I need an api key, right?
-----from documentation ----
POST /rest/auth/login HTTP/1.1
Host: your-domain.com
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

username=myUserName&apikey=myApiKey

Where I can find the "myApiKey"?

Daniel Corn
@cundd
Hi! I'm sorry, I don't have a C# example.
The API-key can be found/must be added to the Frontend User in the TYPO3 backend
Skeferstat
@Skeferstat
Hi, Daniel. But maybe an curl example?
Daniel Corn
@cundd
@Skeferstat not a finished one... One would start with creating the mapping for a VirtualObject and configure the path to allow access to the FeUsers (https://rest.corn.rest/Configuration/Basic/).
Maybe you could also go with \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository instead of the VirtualObject
Jens Thiele
@JeThGa
Hi i have am question to the basicAuth,
i have this virtual_object-powermail_mail {
path = virtual_object-powermail_mail
read = require
write = deny
} and an frontend User with an API Key but i get allways the message error "Unauthorized"
Jens Thiele
@JeThGa
I try to connect the a php script and also with the browser but the message is always the same.
Daniel Corn
@cundd
@JeThGa which webserver are you using? Maybe something like https://rest.corn.rest/Configuration/Authentication/#basic-auth will help
Jens Thiele
@JeThGa
@cundd the rewriteRule is also set
I also tried to login as the frontend-user but the problem is always the same
Daniel Corn
@cundd
Jens Thiele
@JeThGa
Yes, now it works with the Login Request.
Daniel Corn
@cundd
It's strange that BasicAuth doesn't work than.
I think that i have a small Problem in the script but now i am on o good way. Thank you
Daniel Corn
@cundd
But it does still only work the Login Request and not with Basic Auth?
Jens Thiele
@JeThGa
Now, it works the Basic Auth
Daniel Corn
@cundd
Ah ok :sweat_smile:
César Hansy Dueñas Barragán
@caessard
Hi Daniel, I was implemented the extension and works in subdirectory example http://111.111.111.111/subdirectory/rest/news/ the behaviour was correct but after configuring domain in sitehttp://domain.co/rest/news. I am receiving {
"error": "Forbidden"
} . What have to modify more?