XF 2.2 getting the post ID from API Post -> post

Dannymh

Active member
I am using the API and the Thread/Post endpoint to create a post. however in doing so this does not return any data, just an http code.

I was hoping to get the post ID of the created post so that I can use this later in linking the two systems up.

Is there any inbuilt mechanism, or do i need to build an addon to the API to return something? Otherwise is there a way for me to get that post ID straight after its created and return it to the system calling the API?

Regards
Daniel
 
Looking at the code, I think that endpoint should actually be returning a post entity (even if it isn't documented), but it's a bit late here so I don't have a chance to test it out right this second.
 
Looking at the code, I think that endpoint should actually be returning a post entity (even if it isn't documented), but it's a bit late here so I don't have a chance to test it out right this second.
I thought it was earlier when I used postman but coming null now. I'll retest it and see. Thanks
 
I don't think we ever actually return an empty body, except maybe for something that returns a 3xx response code. If we're returning a 200 then it should certainly have content.

The output of POSTS posts/ does appear to be missing in the docs, but it will be returning the created post (along with a success indicator).
 
I don't think we ever actually return an empty body, except maybe for something that returns a 3xx response code. If we're returning a 200 then it should certainly have content.

The output of POSTS posts/ does appear to be missing in the docs, but it will be returning the created post (along with a success indicator).
Thank you. It was returning blank in my test site but looking at the code it should be returning the post data.

I'll re-test it this weekend to see what might have been happening. I was only getting the 200 ok, but I am using promises in guzzle and that may be part of the response issue
 
Just closing the loop on this, I was for some reason not functioning as an adult and returned $response instead of $response->getBody()->getContents()

Returning the full getContents pulls in the foreign post entity from the response body
 
Last edited:
Top Bottom