Thanks! That worked perfectly. I had seen that but I didn't notice that the
parameters in that example were a JSON string, so I thought it was still
being defined as a hash.

On Mon, 12 Oct 2020 at 16:23, Phil Pirozhkov <[email protected]> wrote:

> You may want to check this out
> https://relishapp.com/rspec/rspec-rails/v/4-0/docs/request-specs/request-spec#providing-json-data
> So I guess it should be:
> ```
>
> post "/api/path", params: data, headers: { "CONTENT_TYPE" => "text/xml" }
> ```
>
>
> On Mon, Oct 12, 2020 at 6:14 PM [email protected] <[email protected]>
> wrote:
>
>> Hi.
>>
>> I need to create an API that will accept XML. How can I specify an XML
>> body in a request spec? I have tried:
>>
>> data = (xml as a string)
>> post '/api/path', env: { 'RAW_POST_BODY' => data, 'Content-Type' =>
>> 'text/xml' }
>>
>> and then I can access the body as request.body.read but the values do not
>> appear in the params. Obviously, I could pass the parameters with 'params:
>> { key: value, ... }' but I'd prefer to be able to test with samples of the
>> body as they are going to be sent.
>>
>> Regards,
>>
>> Joe
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "rspec" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rspec/10d88f3c-eb7b-47f3-94f6-e6b5b14aff10n%40googlegroups.com
>> <https://groups.google.com/d/msgid/rspec/10d88f3c-eb7b-47f3-94f6-e6b5b14aff10n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/CAAk5Ok8gcqUwot%2BvrCXmNq%2B8tJoeg4EkoXY5qhRQyruTCUKLXw%40mail.gmail.com
> <https://groups.google.com/d/msgid/rspec/CAAk5Ok8gcqUwot%2BvrCXmNq%2B8tJoeg4EkoXY5qhRQyruTCUKLXw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CAKRXwc1JqLDgVUUJHrTLGdHHtj30Jt%2BRQqZ%2B6N1aQQUh_6dpkw%40mail.gmail.com.

Reply via email to