content-and-experience-toolkit icon indicating copy to clipboard operation
content-and-experience-toolkit copied to clipboard

Toolkit doesn't forward documents POST body

Open tcaruth opened this issue 3 years ago • 3 comments
trafficstars

Attempted making the following call within a component. Locally through the toolkit, it doesn't work. If I upload the component to an OCM instance, my folders are created.

const reqFetch = await fetch(`/documents/api/1.2/folders/${strParentFolderId}`, {
	body: JSON.stringify({
		name: strFolderName,
		description: strFolderDescription
	}),
	headers: {
		'Authorization': `session`,
		'Content-Type': 'application/json'
	},
	method: 'post'
})
const objResponse = await reqFetch.json()

I believe the toolkit isn't passing the body of my request on, since the error I get looks like this:

{
  "errorCode": "-97",
  "errorKey": "!csFldUnableToCreateFolder!csItemMustSpecifyName",
  "errorMessage": "Unable to create folder. You must specify an item name.",
  "title": "Unable to create folder. You must specify an item name.",
  "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}

See relevant code on/around this section of the documentsRouter https://github.com/oracle/content-and-experience-toolkit/blob/46740c3859d5e36ce1e4daaee2eebd5c77590587/sites/test/server/documentsRouter.js#L116

@hzeng99 @BrianJCheyne Can this be addressed, or was it intentionally left out?

tcaruth avatar Feb 08 '22 23:02 tcaruth

Currently the local server only supports rendering the OOTB documents related components.

hzeng99 avatar Feb 08 '22 23:02 hzeng99

Meaning you can't create folders with the API while running through the toolkit?

tcaruth avatar Feb 09 '22 00:02 tcaruth

I know pull requests aren't typically merged or used in this repository. #18 is simply for other toolkit users to have a quick reference if they also need to be able to test this API locally.

tcaruth avatar Feb 09 '22 00:02 tcaruth