diff --git a/src/app/services/actions/query-action-creator-util.ts b/src/app/services/actions/query-action-creator-util.ts index e87f17890..807d1dcd5 100644 --- a/src/app/services/actions/query-action-creator-util.ts +++ b/src/app/services/actions/query-action-creator-util.ts @@ -70,7 +70,8 @@ export function createAnonymousRequest(query: IQuery, proxyUrl: string, queryRun const options: IRequestOptions = { method: query.selectedVerb, - headers + headers, + body: query.sampleBody ? JSON.stringify(query.sampleBody) : undefined }; return { graphUrl, options }; } diff --git a/src/app/views/query-runner/query-input/QueryInput.tsx b/src/app/views/query-runner/query-input/QueryInput.tsx index c46556536..ad6818ed3 100644 --- a/src/app/views/query-runner/query-input/QueryInput.tsx +++ b/src/app/views/query-runner/query-input/QueryInput.tsx @@ -10,6 +10,7 @@ import { getStyleFor } from '../../../utils/http-methods.utils'; import { parseSampleUrl } from '../../../utils/sample-url-generation'; import { translateMessage } from '../../../utils/translate-messages'; import SubmitButton from '../../../views/common/submit-button/SubmitButton'; +import { shouldRunQuery } from '../../sidebar/sample-queries/sample-query-utils'; import { queryRunnerStyles } from '../QueryRunner.styles'; import { AutoComplete } from './auto-complete'; import { ShareButton } from './share-query'; @@ -36,7 +37,10 @@ const QueryInput = (props: IQueryInputProps) => { const authenticated = !!authToken.token; const { mobileScreen } = sidebarProperties; - const showError = !authenticated && sampleQuery.selectedVerb !== 'GET'; + const showError = !shouldRunQuery({ + method: sampleQuery.selectedVerb, authenticated, + url: sampleQuery.sampleUrl + }); const { queryButtonStyles, verbSelector, shareQueryButtonStyles } = queryRunnerStyles(); verbSelector.title = { ...verbSelector.title, diff --git a/src/app/views/sidebar/sample-queries/SampleQueries.tsx b/src/app/views/sidebar/sample-queries/SampleQueries.tsx index 3906e5c1d..dd7a24daf 100644 --- a/src/app/views/sidebar/sample-queries/SampleQueries.tsx +++ b/src/app/views/sidebar/sample-queries/SampleQueries.tsx @@ -25,7 +25,7 @@ import { classNames } from '../../classnames'; import { NoResultsFound } from '../sidebar-utils/SearchResult'; import { sidebarStyles } from '../Sidebar.styles'; import { - isJsonString, performSearch, trackDocumentLinkClickedEvent, + isJsonString, performSearch, shouldRunQuery, trackDocumentLinkClickedEvent, trackSampleQueryClickEvent } from './sample-query-utils'; @@ -167,7 +167,7 @@ const UnstyledSampleQueries = (sampleProps?: ISampleQueriesProps): JSX.Element = onRender: (item: ISampleQuery) => { const signInText = translateMessage('Sign In to try this sample'); - if (item.method === 'GET' || tokenPresent) { + if (shouldRunQuery({ method: item.method, authenticated: tokenPresent, url: item.requestUrl })) { return