# Can't send PM via API (HTTPUnprocessableEntity 422)

**URL:** <https://meta.discourse.org/t/cant-send-pm-via-api-httpunprocessableentity-422/55017>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [January 1, 2017, 4:04am UTC](https://meta.discourse.org/t/cant-send-pm-via-api-httpunprocessableentity-422/55017 "2017-01-01T04:04:24Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)\
**Post date:** [January 1, 2017, 4:04am UTC](https://meta.discourse.org/t/cant-send-pm-via-api-httpunprocessableentity-422/55017/1 "2017-01-01T04:04:24Z")

</div>

Anyone know what I am doing wrong here please? It was working fine, then I don’t know what I did but it stopped working. I’ve stripped it back to this and it’s still not working:

```plaintext
irb> require 'uri'
=> true

irb> require 'net/http'
=> true

irb> Net::HTTP.post_form(URI.parse("https://forum.com/posts?api_key=12345&api_username=MyForum"), {title: "test", raw: "test", archetype: "private_message", target_usernames: "Me"})

=> #<Net::HTTPUnprocessableEntity 422 Unprocessable Entity readbody=true>
irb(main):004:0> 

```

I can’t even get this to work:

```plaintext
curl https://forum.com/posts?api_key=12345&api_username=MyForum&archetype=private_message&title=title&raw=message&target_usernames=Me

```

Any idea what’s going on?

---

_[View the full topic](https://meta.discourse.org/t/cant-send-pm-via-api-httpunprocessableentity-422/55017)._
