Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send JSON payloads properly #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jslag
Copy link

@jslag jslag commented Sep 14, 2022

storyblok_ruby's call to RestClient::Resource was causing payloads for PUT and POST to be sent as application/x-www-form-urlencoded, rather than application/json. This was causing booleans to be interpreted as strings when updating stories.

This PR updates calls to match the to_json examples at https://github.com/rest-client/rest-client

Pull request type

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Other (please describe):

How to test this PR

  • you'll need a story with a boolean value
  • update the story via the API, something like
story_client = Storyblok::Client.new(oauth_token: 'TOKEN', api_url: 'mapi.storyblok.com', api_version: 1)
url = "spaces/SPACE/stories/STORY"
story = story_client.get(url)
payload = story['data']['story']
payload['name'] = 'something different'
story_client.put(url, { "story" => payload })
  • reload the story, and check the Draft JSON. The previously boolean value will now be a string.

What is the new behavior?

With this PR, booleans stay boolean when stories are updated as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant