GeekInTheNorth / Stott.Optimizely.RobotsHandler

An admin extension for Optimizely CMS 12+ for managing robots.txt on a per site basis.
MIT License
3 stars 3 forks source link

Error while saving robots text in CMS 12 #16

Closed Anish-Peethambaran closed 2 years ago

Anish-Peethambaran commented 2 years ago

I am getting this error "Oh Dear! An error was encountered when trying to save your robots.txt content." while saving robots text. Response header had the error "siteId is not a non-null non-empty value. (Parameter 'siteId')". On debug I could find that the error is thrown from "RobotsAdmin.js". The response from "/Robots/Details/" is wrongly fetched from response data. When I changed "siteId" to "SiteId" it worked well. Also, robots text is not populating in the text area but browsing robots.txt shows data. Response data: SiteId | "9b309655-d409-4b2b-a370-784fad2dc162" SiteName | "foundation" RobotsContent | "robots text content"

Wrong selection, may be a typo : $('.js-modal-title').html(data.siteName); $('.js-modal-siteid').html(data.siteId); $('.js-modal-robots-content').val(data.robotsContent);

image

image

GeekInTheNorth commented 2 years ago

Hello Anish,

Thank you for the report, hopefully we can resolve this for you. In testing I get the following response from the API endpoint:

{
    "siteId": "c14aa234-6e47-4a0f-b2f6-a11a66c5385c",
    "siteName": "CMS 12",
    "robotsContent": "User-agent: *\nDisallow: /episerver/\nDisallow: /utils/\n\nSitemap: https://localhost:44344/cms-12c.xml"
}

What do you have configured as your default JSON handler and serialization options for you solution? I may have to update the API to force a specific serialization options to suit the JavaScript methods.

GeekInTheNorth commented 2 years ago

@Anish-Peethambaran I have updated the API endpoints to format the JSON in the format expected by the UI and I have pushed a 1.0.3 version of the nuget package to the Optimizely nuget feed. It usually takes a working day for package updates to appear in the Optimizely nuget feed.

GeekInTheNorth commented 2 years ago

@Anish-Peethambaran I've now completely segregated the serialization of JSON of the plugin so that it is not dependant upon the client's solution meeting a specific format. 1.0.3 had an issue where if you used Newtonsoft.Json instead of System.Text.Json, an error would be thrown due to serializer incompatibility.

This has now been tested on Chrome & Edge with both Newtonsoft.Json and System.Text.Json being used within the sample solution.

Please watch out for 1.0.4 appearing on the nuget feed.

GeekInTheNorth commented 2 years ago

@Anish-Peethambaran 1.0.4 is now available on the nuget feed and should resolve this issue. Please reopen the issue if it continues to be a problem.

Anish-Peethambaran commented 2 years ago

@Anish-Peethambaran 1.0.4 is now available on the nuget feed and should resolve this issue. Please reopen the issue if it continues to be a problem.

Many thanks @GeekInTheNorth . I really appreciate your timely response in fixing the issue. I will get the latest version and let you know in case of any issues.