Requesting categories in script returns 202 status with an unknown error

Good morning/afternoon. :slightly_smiling_face:

I’ve been looking into an issue for @crossingthethreshold, who is using my Drafts action for posting to M.b., and I’m a bit stuck and hoping that somebody might be able to help. In the action I present a list of categories to be assigned to a post. However, the categories are no longer showing up for him. I added a logging step to capture the response from the request and it is returning a 202 status code with an Unknown error message.

The properties that I’m using for the request are:

    "url": "",
    "headers": {
        "Authorization": "Bearer [token]",
    "method": "GET",
    "parameters": {
        "q": "category",
        "mp-destination": [selected domain name],

Is there something that I’m doing wrong with the request body or is there something else that we can check, on why the categories are not returning properly?

Thanks, in advance. :slightly_smiling_face:

Interesting! Do we know if categories work in other contexts? For example, looking at @crossingthethreshold’s blog, I see no list of categories on the archive page: I’m on the same theme, and for me, a list of my blog’s categories shows up there:

So, maybe there’s a problem with a category name that contains special characters that break stuff in some cases? For example, I’m just guessing here. :blush:

Update: never mind, I just saw that the categories are there. They are just hidden with CSS. Hmm. :thinking:

Can you share the actual HTTP request and response that happened, @donnydavis? I.e., not the JavaScript code, but the HTTP communication that goes over the network.

Previously he said that one of the categories had a hyphen in it. I have not been able to actually add a category with that, and he has since removed that, but it still breaks. So far, this is the only issue like this that has been reported to me. I have not been able to reproduce it myself.

Let me see if I can get the actual response data.

That’s correct, @Mtt sent me some CSS to add so that my (too long) list of categories could be hidden.

Just to add that I also use this Drafts action to post to and it successfully lists categories. It has done for years, and also makes use of a script. Just sharing in case this is of any help in debugging the problem.

That other script does not make use of mp-destination and instead relies on the currently selected blog in the web interface. So, maybe something is up there? It could be interesting to modify your script to also skip mp-destination, @donnydavis, and see what happens.

@crossingthethreshold I pushed an update, to the test action, to try and log a little more data from the response. Can you try that and share the response data in our forum thread?

After you get the response from that I’ll make another change to remove the mp-destination, as @sod suggested.

I just installed it. Now to put a post together. This might be my most productive blogging day! :smile:


Sorry, I should have mentioned that you don’t actually have to post anything. You can cancel out after you select the blog and it loads the screen with the categories. :see_no_evil:

OK. So I selected the action with no draft entered and it went straight to the attached, and so I canceled out from there.

Yeah, that is good enough. If you look in the log again, it should have some more data from the categories response.

Here it is,

Script step completed.
Script step completed.
Script step completed.
User cancelled action
Script step completed.

Interesting. I wonder if there is a difference with the Mac? Or did the latest update on the test action apply correctly? :thinking:

I was expecting something like this.

Script step completed.
Script step completed.
Category Response Status: 200
Categories Response Data: {"categories":["Stuff","Stuff 2","Stuff3","Stuff4","Stuff5"]}
Response error: Unknown error
Headers: {"access-control-allow-headers":"Authorization, Origin, X-Requested-With, Content-Type, Accept","access-control-allow-methods":"POST, GET, OPTIONS, DELETE","Content-Type":"application/json","Date":"Fri, 27 Oct 2023 14:30:16 GMT","Server":"nginx/1.14.2","Access-Control-Allow-Origin":"*","Connection":"close","Content-Length":"61"}
Script step completed.
User cancelled action
Script step completed.

How would I know if it ‘applied correctly’? Should I reinstall the action? Quit Drafts? Reinstall and quit Drafts? Other…?

Yeah, try to delete it and reinstall it. I’m curious if there was an issue there. Sorry for all of the steps.

Here’s the link again, so you don’t have to go digging for it.

Thank you for the link and saving the digging :wink:

I deleted the action, quit Drafts, opened Drafts back up again, and reinstalled the action.

I then ran it as before and got exactly the same output. The log was no different.

Sorry :cry:

That is very weird. :thinking:

I went ahead and removed the mp-destination from the request as @sod had suggested. This will force the script to request the categories from the blog that is selected on the website and not the one that you select at the beginning of my the Drafts action. After updating the action, you can verify the update by going in to edit the action. Under the first script step, at line 124, you should only see one parameter for "q": "category", there should be no `mp-destination’ at this point.

If that works, one other thing that I wanted to see if you could check. In the website, which blog do you have selected? If you go under Posts, then you can see it at the top. This will probably only be relevant if you have the test blog enabled.

Could you change the selected blog there on the web and then try the action again?

I only have one blog. No test blog. Just the blog that I post to -

I checked the first script and line 124 is as you say.
Just to say that mp-destination is mentioned in line 125: mp-destination:

Gah, what a crazy morning. Got distracted with my daughter and forgot to actual publish the change to remove the mp-destination. :man_facepalming:t3:

Pushed that change, so that it doesn’t include the mp-destination. Post/Update to (test) | Drafts Directory

I deleted the action, quit Drafts, started it up again, installed the updated action, ran it against a blank draft, and cancelled it at that point…and same again. Same Log.

A crazy morning ran into a crazy afternoon?!